i am using visual studio 2019 to create simple asp.net 2.1 mvc project. i have added two more xunit projects in the same solution as the mvc project, however i want to add all these projects to a single source control such as github. so when i try to add a source control it gives me the following caution: "the current solution has project that are located outside of the solution folder. these project will not be source controlled in a git repository." my question is how do i get to consolidate all the project under a single folder and the solution does not break
samedi 27 juillet 2019
Job queued for execution - botium box
i m using tried version of botium. the solution which was provided in previous such issue was to check the heartbeat of botium agent. attaching the screenshot of that as well. i am able connected to kori.ai chatbot and then connected the test set but on running the an error came 'Job queued for execution'
and on doing the live chat with bot .error came '504 gateway timeout' enter image description here
vendredi 26 juillet 2019
Test with multipage methods (Page Objects) - Selenium Webdriver
I have the following problem:
I can only call the method (.confirmaLogin) from the same page (class). Why can't I add methods from other pages?
First page (class):
public class loginSIGE {
public WebDriver browser;
public loginSIGE(WebDriver browser) {
this.browser = browser;
}
public loginSIGE confirmaLogin() {
browser.findElement(By.xpath("//button[@class=\"btn btn-primary btn-block btn-flat\"]")).click();
return new telaPrincipal(browser);
}
Second page:
public class telaPrincipal extends loginSIGE {
public telaPrincipal(WebDriver browser) {
super(browser);
}
public telaPrincipal cliqueDenuncia() {
browser.findElement(By.linkText("Denuncias")).click();
return new telaDenuncia (browser);
}
Test:
public void acesso() {
new loginSIGE(browser)
.confirmaLogin();
I can't add the second page method!
I look forward and thank you in advance
Alert message validation - Test Automation (Selenium)
Good Morning! I'm catching a lot in a setting. Could you help me?
Scenario: I perform an action. It is a temporary (alert) message on the screen. After a few seconds, disappear! What I need: Perform a message validation on this temporary alert.
Below is the location of the element:
**strong text**<div id = "alert-message-20190726103017" class = "top alert danger alert alert fired";>
<button type = "button" class = "close" / button>
<i class = "fa-exclamation icon" / i>
"Invalid username and password" / div>
Can someone help me? Please and thanks!
PHP Unit Testing -- Is this overly mocked? -- Method loops call to other method
FUNCTIONALITY
I have a Laravel project in which I have extended Illuminate\Database\Eloquent\Builder as an AbstractSearch class to introduce a params() method that calls the abstract method applyParams() to be defined when AbstractSearch is extended.
Example:
$models = (new ModelSearch)
->params(['name' => 'Model', 'createdBefore' => now()])
->with(['modelCategory', 'modelType'])
->paginate();
applyParams() is responsible for taking the array parameter from params() and properly constructing the underlying Illuminate\Database\Query\Builder query.
The AbstractSearch class allows casting of these parameters via a protected $casts attribute and a castParams(array $params = []) method.
castParams() loops through the protected $casts attribute and calls $this->castParam($params, $field, $cast) for each element.
Right now, both castParams() and castParam() are public methods, even though the likelihood of castParam() ever being called that way is practically zero.
Relevent excerpt from AbstractSearch:
public function params(array $params = [])
{
return $this->applyParams(
$this->prepareParams($params)
);
}
abstract function applyParams(array $params = []);
public function prepareParams(array $params = []) : array
{
return $this->castParams(
$this->applyDefaults($params)
);
}
public function applyDefaults(array $params = []) : array
{
foreach ($this->defaults as $field => $value) {
data_fill($params, $field, $value);
}
return $params;
}
public function getCasts()
{
return $this->casts;
}
public function castParams(array $params = []) : array
{
foreach ($this->getCasts() as $field => $cast) {
$this->castParam($params, $field, $cast);
}
return $params;
}
public function castParam(&$params, $field, $cast)
{
if (! isset($params[$field])) {
return;
}
switch ($cast) {
case 'date':
case 'datetime':
if (! $params[$field] instanceof Carbon) {
$params[$field] = Carbon::parse($params[$field]);
}
break;
default:
break;
}
}
TESTING
I have unit tests in place for both methods. The bulk of the testing is done on castParam() to ensure that casting is done properly.
The unit test for castParams() is done with a partial mock of the AbstractSearch class that expects various calls to castParam().
QUESTIONS
I recently re-read some unit testing principles that made me question this class's setup. You can see from the excerpt above that there are a lot of public methods that should probably be protected. In fact, the only method that needs to be public is params().
It logically follows that params() should be the only public method; however, params() relies on the abstract method applyParams() so any test of params() would have to be done on the extending class because the results rely on what applyParams() does.
So...
-
Have I talked myself to the right spot with the above two paragraphs? It sounds right to me, but it would involve testing that
params()returns an instance ofIlluminate\Database\Eloquent\Builderand that the expected changes were made to the Builder's underlyingIlluminate\Database\Query\Builderand its query. I'm not entirely sure that's even possible. -
Going back to
castParams()and the partial mock's expectations that it will callcastParam()several times. If bothcastParams()andcastParam()remain public methods and if testing should focus on observable behavior, won't I have redundant tests if I test both? Or is it generally acceptable to mock thecastParam()calls in mycastParams()test sincecastParam()will be thoroughly tested?
Is it possible to set the Allure description of a test from another language?
I am discovering tests from another language (cpp) in my pytest suite.
class CatchTestItem(pytest.Item):
def __init__(self, name, parent, test):
super(CatchTestItem, self).__init__(name, parent)
self.test = test
self.add_marker('catch_test')
self.__doc__ = test[3]
self.tags = test[4]
def runtest(self):
pass
def reportinfo(self):
return self.fspath, self.test[2], self.name, self.test[3]
class CatchTestFile(pytest.File):
def __init__(self, fspath, executable_path, parent=None, config=None, session=None, nodeid=None):
self.tests = []
self.executable_path = executable_path
super(self.__class__, self).__init__(fspath, parent, config, session, nodeid)
def _add_test(self, test_name, test_path, test_line, test_desc, test_tags):
self.tests.append((test_name, test_path, test_line, test_tags, test_desc))
def collect(self):
test_exe = str(self.executable_path)
...
I am wondering if it is possible, possibly in CatchTestItem, to set the allure description of the discovered test?
Ordinarily, the description is discovered from the docstring of the pytest function - but since these aren't pytest functions, how can I set the description for them?
How do I send an email from a mailer in a test environment
I want to send an email from a mailer during a unit-test. I have an empty fixture directory in /tests/fixtures/user_mailer/invite.yml
I run the code in the rails console and the mailer sends successfully. However, I cannot call the class and the method from within the test itself, even when I try dropping in a binding.pry and calling the mailer manually.
require 'test_helper'
class UserMailerTest < ActionMailer::TestCase
test "invite" do
# Create the email and store it for further assertions
email = UserMailer.create_invite('me@example.com',
'friend@example.com', Time.now)
# Send the email, then test that it got queued
assert_emails 1 do
email.deliver_now
end
# Test the body of the sent email contains what we expect it to
assert_equal read_fixture('invite').join, email.body.to_s
end
end
The error Message I receive is:
UserMailerTest#invite[/Users/richardjarram/code/catonmat/yap-backend/test/mailers/bug_mailer_test.rb:10]:
1 emails expected, but 0 were sent.
Expected: 1
Actual: 0