Hot to print test summary after every test run - junit5

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.

Related

How to Skip the passed test cases in Cucumber-QAF setup

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.

How to handle failures in Test Suite in selenium webdriver

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.

Selenium Automation retry failed tests using TESTNG

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

Running Selenium Tests in Parallel

I have selenium test that takes 1 minute to complete . If I want to run this 1000 times I have to wait 16 hours . Is there any way I can run 5 tests in parallel so that it can be done in 3 hours ? I have generated a JUnit test scrip and tried to run in with multiple threads but they end up using the same Firefox window . I don't want to run this on grid cause running 5 Firefox window is not that resource intensive.
Thanks
By using below logic you can run your junit cases in parallel.
Class[] cls={test1.class,test2.class,test3.class,test4.class};
JUnitCore.runClasses(new ParallelComputer(true,false),cls);
In above method first parameter of ParallelComputer() indicates classes and second one is for methods. Here I'm running classes in parallel but not methods.
ParallelComputer Class documentation
http://junit-team.github.io/junit/javadoc/4.10/org/junit/experimental/ParallelComputer.html
Try with this example
http://mycila.googlecode.com/svn/sandbox/src/main/java/com/mycila/sandbox/junit/runner/
The file to launch is MySuite.java. Works well for me.

Adding time stamp to gradle test output

We use function tests in a java project that we run with junit and gradle. They take some time. Several minutes per test and we have 200. The test output looks something like this:
TEST testname1(location) PASSED/FAILED
TEST testname2(location) PASSED/FAILED
So when we look at the log we don't know if it was test1 or test2 that took time. Is it possible to add a timestamp to the gradle output?
datetime: TEST testname1(location) PASSED/FAILED
datetime: TEST testname2(location) PASSED/FAILED
And also is it possible to write testname before we know if the test passes or failes? So if a test hangs we will see which test that is hanging?
The new test logging feature in Gradle 1.1 will help you with this. You can already try 1.1-rc-2 today.
The other options is to implement and register a custom org.gradle.api.tasks.testing.TestListener. See the java/testListener sample in the full Gradle distribution.