Can someone please suggest me how to prepare test scripts for batch test execution using testng... I have around 1000 testcases with different test data iteration...
Also I want to execute failed test cases after complete execution of test suite. Suppose there were 1000 test cases and 200 failed then I want to run that 200 again
You could simply rerun the tests by calling testng-failed.xml
http://testng.org/doc/documentation-main.html#rerunning
Or you could implement the IRetryAnalyzer
http://seleniumworks.blogspot.co.uk/2013/12/re-run-failed-tests-automatically.html
Related
I am using Junit 5 and ant and i want to print junit test summary(number of tests passed/failed till now) after every test run.
Is there a way to do this?
The way to go is registering a test execution listener (see https://junit.org/junit5/docs/current/user-guide/#running-tests-listeners) and updating your own summary.
my problem is that I made two test cases which are perfectly fine and working nicely, however I need to run second one only if first one fails. How can I do that? I'm using RIDE Robotframework and working on IE, because of legacy app.
What you can do is make tests:
Test A passes.
Test A fails.
Test A fails and runs test B.
However I'd prefer you wouldn't do that. Usually tests should be logically separate. If you could you would run all of them on parallel.
If a test fails you shouldn't be concerned with testing other stuff at that point. You should fix the first test. Otherwise you will go in a rabbit hole of tests.
You can't do what you want. At least, not directly. Robot provides no way to add additional tests after the tests have started running.
However, if instead of "run second one" you say "run a special keyword", you can move the functionality to a keyword and call it in a test teardown using Run keyword if test failed
*** Keywords ***
On test teardown
run keyword if test failed
... log BUMMER! WARN
*** Test Cases ***
Passing test
[Teardown] On test teardown
log hello, world
Failing test
[Teardown] On test teardown
fail this test has failed.
You could use Pass Execution If keyword with suite variables. This is not perfect solution because Test B is still logged as passed.
*** Test Cases ***
Test A
Set Suite Variable ${a_passed} ${FALSE}
Fail This case failed
Set Suite Variable ${a_passed} ${TRUE}
Test B
Pass Execution If ${a_passed} A passed so skipping B
Log To Console Running Test B
I have a project where I am running 100 scenarios every day. After the run has complete, through listeners I am updating the pass/fail in an Excel sheet. I want to hear about a solution where, if I am running the test suite again, the passed test cases should be skipped and only failed test cases should run. I dont want to use retry.I tried to use skipException in beforeInvocation listener method but the test case is still executing the passed test case. How can I skip the passed test cases and execute only the failed one through listeners ?
Every time before the start of the scenario, it should go to the listener and check the excel sheet whether the scenario is passed or fail. If passed then the scenario should be skipped.
Any help will be greatly appreciated.
Update: I am able to do it through listeners, with skipException, but in my report it is showing test as failed and not as skipped
When you run bdd tests, qaf generates configuration file with name testng-failed-qas.xml under reports dir. You should use that config file to run only failed scenarios.
I run the test on bamboo with selenium technology and the test tab does not show the test failure, how I can view the test failure?
To see test results (including info which test caused fail) you need to add proper parser task to your job. There are many available parser tasks i.e. JUnit Parser, NUnit Parser, TestNG Parser.
The important thing is to move parser task under Final tasks bar (parser will execute even if previous task fail).
You don't have any test failures. In fact, no tests were running in this build as you can see in line
0 test in total
You job may have failed for one of 2 reasons:
Actual failure of the job. Check detailed log on Logs tab to see if this is the case
It may have also failed because you configured it to fail when there was no tests (and in this case there was no tests indeed) as we see. The corresponding configuration would look like this:
Suppose I have 10 test cases in my Test suite and when I execute the Test suite I get an error for test case no.7.
Now is there any way that I can restart my execution from test case no.7 after correcting the changes?
I'm using TestNG.
Do we have recovery scenarios in Selenium?
TestNG generates .xml configuration with failed tests http://testng.org/doc/documentation-main.html#rerunning
Or you can use org.testng.IRetryAnalyzer which runs failed tests again and you have more control over it.
Example here http://seleniumeasy.com/testng-tutorials/execute-only-failed-test-cases-using-iretryanalyzer.
Yes you can do that if you are using Eclipse IDE. Click on the arrow just before test class name, it will show you all the methods(test cases) of that test class. Right click on the one which you want to run. It will run that specific test only.