CucumberRunner show progress of how many scenarios left to be excecuted - java

I have a lot of Acceptance tests that runs with CucumberRunner. When it starts I have no idea in awhile how many scenarios left to be executed. Is there any way how i can print in the terminal like:
Scenario(10 of 1000) Call A() will add new object
Scenario(11 of 1000) Call B() will open new window
....
etc
Regards

Try using QAF Gherkin client it has live reporting feature which not only shows you the total vs completed test count but you also can see detailed report of completed test during execution.

Related

Test JavaFX Applications by using JUnit

I want to test javaFX application by using junit. I checked several approaches as follow:
user TestFX api: these api works sometime on a test method, in other word, for some execution of a special test, it's work !!!
List use JFXRunner : I used test runner which is defined in this question, but it for a few of the methods to be run and when number of test methods be large(e.g. >20) , test methods waiting forever !!!
define a test runner class such as JavaFXThreadingRule which has been intruduced in this question. these approach works only for a single test and when run some test, test method go into waiting forever same as JFXRunner.
what is the problem really? by debugging test method, I found that by using lath for initializing javaFX, after running several method, remaining method will be waiting for ever. When I set a special time for awaiting method of lath, it work's correctly by it is not logically to set a constant time to test application. How can solve this problem.
for approach 2,3; I used Platform.exit() command for exiting from GUI Application; so test runner which use latch to initialize JavaFX platform wait forever. So, it was my code fault.So, calling Platform.exit() method prevents to execute remaining test methods.

Run multiple selenium tests from a single class(java)

I am writing several different selenium tests as page objects, and want to be able to run them from within a single, central class. I have figured out how to run one test from a different class, but when I try to run multiple tests, only a single one will complete.
I have tried running them sequentially with org.junit.runner.JUnitCore.main("com.etc"), but after
testing the first class, the entire test ends. In the code:
org.junit.runner.JUnitCore.main("com.etc.test.HomePageCheck");
System.out.print("test");
the print command is never run, even if the test runs successfully
I have also tried creating multiple threads, but once any test completes, the whole process seems to end and leave the remaining tests hanging.
To reiterate, I have Class1 with several jUnit tests, and Class2 with other jUnit tests. I want to be able to run a Class3, whcih will run both Class1 and Class2 and complete all tests for those other classes.
I do not think I want to use Selenium Grid, I would rather just run the tests locally on a machine, either in sequence or, preferably, in parallel.
I figured it out, here is the code(second line is key, the others are just to get the output)
Result aTest;
aTest= org.junit.runner.JUnitCore.runClasses(new Class<?>[]
{
Events.class,SearchCheck.class});
for(Failure i:aTest.getFailures())
{
System.out.println(i.getException()+"\nat: "+i.getDescription());
System.out.println("trace: "+i.getTrace());
System.out.println();
}
}
Thanks everyone
Edit: actually testSuite also works extremely, and is probably the better way to do this.

Gradle Test, run verbosely?

We have a task in our Gradle build file called integration which extends Test and is used to run all of our integration tests. Our integration tests take quite some time to run because we have, as you might expect, quite a few. And several of them can run for up to 10 minutes because of some lengthy DB interactions.
Right now all I can see when they are running is >Building > :integration. And it sits at that point for...a very long time. I'm often not sure if it's just in the middle of a bunch of long tests, or if it's hanging on something it really shouldn't be hanging on.
So, I was wondering if there is a way to get them to run verbosely? So I can see which test we are actually on? I just want the command line to spit out something like:
Running test <testName>: Started...Complete (231 sec)
I've looked through the Gradle documentation and haven't seen anything that shows how this might be done. Granted, I am a little new at this, so... If anyone has an idea how this could be done? I would prefer to have a flag that just does it, but if it can be done with some scripting I'm willing to learn. Just point me in that direction...
Have a look at this DSL doc. In general what You need is make use of beforeTest and afterTest closures. You can keep the invocation start in a global map.
def times = [:]
test {
beforeTest { td ->
times[td.name] = System.currentTimeMillis()
println "$td.name started"
}
afterTest { td ->
println "$td.name finished in ${System.currentTimeMillis() - times[td.name]}"
}
}
I'm not sure if this is synchronous. You need to try.

How to wait X minutes between tests in TestNG

I am testing a website that has a page that will update 4-5 minutes after I have done a certain action.
Here's what I've thought of:
Thread.sleep()/Continuously refreshing page waiting for update. This means my tests automatically get an additional 5 minutes added on.
I have a set of tests that are ordered by DependsOnMethod in a lengthy list. I could depend the first test on the test that performs the action, and have the second test depend on the last test to run. This option is not as bad...but it means putting the methods in a class that is completely irrelevant (and dependencies that don't make logical sense)
Are there any other options?
Note: I am using TestNG with WebDriver
Best solution would be to use implicit or explicit waits but it depends how the page update looks like. But if it's for instance some element with counter, you should try something like.
WebElement myDynamicElement = (new WebDriverWait(driver, 5 * 60)) //time in seconds
.until(ExpectedConditions.textToBePresentInElement(By.id("id"),
"Text after update"));

JUnit - Only record test time on the actual #Test function

I am noticing that JUnit (on Eclipse Indigo at least) is reporting the time of each test, including the #Before and #After setup and tear down functions.
I'd like to only see the time it takes the individual #Test functions to run, sans the overhead setup and teardown.
Don't get me wrong, I can see why including the setup and tear down can be important, but for my purposes, separating them would be more beneficial.
These tests really ought to take a matter of milliseconds. Hopefully I can do this without having to write my own/use Apache stopwatch function!
// Using JUnit 4, Java 6, Eclipse Indigo
Could there be a way to overload/override the JUnit reported time of test run with a manual #?
UPDATE:
It appears the timing of the function is in private methods found here:
https://github.com/junit-team/junit/blob/72af03c49fdad5f10e36c7eb4e7045feb971d253/src/main/java/org/junit/runner/Result.java
Since they aren't protected, I don't think we can override the start and stop times...
You can include a time stamp as the first line in your #Test functions, and another time stamp as the last line in the #Test functions. A simple calculation of the difference between the two times would show how long the test itself take without the setup and tear down parts.

Categories