Adding time stamp to gradle test output - testing

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.

Related

Hot to print test summary after every test run

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.

Viewing test results for a failure on bamboo

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:

Intellij running one test in TestNG

So my typical workflow is
I write a data driven test using TestNG in IntelliJ.
I supply hundreds of data items
Run the test and one or two of them fail
I see the list of passed/failed tests in the "Run" pane.
I would like the ability to just right click that "instance" of the test and run that test alone (with breakpoints). Currently IntelliJ does not seem to have that feature. I would have to right click the test and when I run, it runs the whole set of tests with hundreds of data points.
Is this possible?
TestNG supports this at the testng.xml level, where you can specify which indices of your data provider should be used. It's called "invocation-numbers" and you can see what it looks like by running a test with a data provider, failing some of its invocation numbers and looking at the testng-failed.xml that gets generated.
Back to your question: your IDE needs to support this feature in order to make it available in the UI, so I suggest you ask on the IDEA forums
The feature has been added as of Intellij 142.1217: https://youtrack.jetbrains.com/issue/IDEA-57906

Merge unit test reports from multi projects Gradle build

I have a multi module Gradle script with 3 modules: common, services and web.
If I run gradle check all the test suite is performed correctly, but I don't have a single test report instead I found a test report for each subproject. How can I merge the test results?
If useful this is the script I'm using https://github.com/CarloMicieli/trenako/blob/master/build.gradle
Thanks
Carlo
The Gradle source contains a Task class used to accomplish this, which unfortunately isn't available in the public API. Basically all it does is copy all of the test reports from various projects into one directory and then run the standard test report task to get an aggregate. Check out the source code at https://github.com/gradle/gradle/blob/master/buildSrc/src/main/groovy/org/gradle/build/TestReportAggregator.groovy

Selenium Test Runner and variables problem

In my selenium test suite (html), I define a first test case to initialize variable called in the next test case.
Sample :
In first script :
store|//div[#id="myfield"]|myvar
In my second script :
type|${myvar}|myvalue
But when I start test runner (from maven), it returns an error telling that ${myvar} is not found
The value contained in the stored var is not used.
Any suggestion ?
Thans a lot
Maybe you could use cookies to store variable?
createCookie is in selenium and to read it you might use javascrpt(getEval)
As far as I know you cannot reference variables declared in a different test when running HTML suites.
What you need is Test and/or Suite "Setup" and "Teardown" functionality.
Test setup and teardown happen before and after each test. Suite setup and teardown only happen once, before and after the suite is run.
As you are using Maven, I assume that your development is in Java, so you could use JUnit
http://www.junit.org/
This has both test and suite setup and teardown:
Test Setup
http://kentbeck.github.com/junit/javadoc/latest/org/junit/Before.html
Test Teardown
http://kentbeck.github.com/junit/javadoc/latest/org/junit/After.html
Suite Setup
http://kentbeck.github.com/junit/javadoc/latest/org/junit/BeforeClass.html
Suite Teardown
http://kentbeck.github.com/junit/javadoc/latest/org/junit/AfterClass.html
I've created separate tests in Selenium IDE and then batched them in a test suite
After that ... when I ran them, the ${variable_name} stored in test 1 works fine in test 2.
Damien
The current version of selenium test runner doesn't pass variables from test to test like the IDE does. There is a javascript work around, check out Nick G's post on http://jira.openqa.org/browse/SEL-605