Determining the Gradle test execution order - gradle

I was wondering whether it's possible to obtain information about test execution order somehow.
I have a project in Maven and all the tests are passing. After I migrated the project to Gradle, one of the tests started failing. The test itself is working: when I execute gradle test -Dtest.single=..., it passes. However, when I run the tests for the whole project, the test fails.
It's possible that some tests that run before the failing test do not release resources correctly and therefore the test fails. But I need to somehow find out which tests are causing this problem.

Tell Gradle to log more events about test processing. There is a documentation how to do that http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.logging.TestLoggingContainer.html

The beforeTest method can be used to output details about each test before it is run, based on a TestDescriptor for each test:
test {
beforeTest { testDescriptor ->
println "${testDescriptor.className} > ${testDescriptor.name} STARTED"
}
}

Related

Disable Integration test case using gradle command in springboot

I am using POSTGRES SQL as DB for my springboot application .Sonarqube integration test cases fail as SonarQube is unable to connect to DB.How can i disable my integration test cases using gradlew command during Jenkins build ?
Below is link where i have shown my code in detail SonarQube does not calculate code coverage
You would likely have to have some kind of naming convention for the tests you wish to exclude. Then, you can readily exclude them using something like the following:
In your build.gradle file, add:
test {
if (project.hasProperty('excludeTests')) {
exclude project.property('excludeTests')
}
}
From the command line:
gradle test -PexcludeTests=**/Integration*

How pass Gradle command parameters to execute a task through Buildship

I know that if in Gradle I use: build -x test it builds and the test are not executed.
In STS with Buildship for support with Gradle, for example for Spring Integration
It has the following two tasks of my interest (build and test):
I can build with the following:
Because some test fails (randomly) I want skip the tests, so I tried
it fails with:
So I tried with:
And fails with
And with:
Nothing happens, only shows the following and stopping:
So how represent build -x test correctly with Buildship?
You must supply -x test as Program Arguments like this:
Or you just run assemble instead of build. assemble is a lifecycle task that aggregates all archive tasks in the project and, besides other tasks, does not execute check tasks, such as test.

Run a single Runner class through gradle command line - karate

I have more than one runner class created in my src/test/java folder. When i run the gradle command by
gradle test -DcatsRunner
it runs all the Runner files inside the folder and not just one. How to run only one Runner file using gradle command line
gradle test -DcatsRunner
You want to run a single test case with gradle.
Running gradle help --task test will give you the following help message:
$ gradle help --task test
Configuration on demand is an incubating feature.
> Task :help
Detailed task information for test
Path
:test
Type
Test (org.gradle.api.tasks.testing.Test)
Options
--debug-jvm Enable debugging for the test process. The process is started suspended and listening on port 5005.
--fail-fast Stops test execution after the first failed test.
--tests Sets test class or method name to be included, '*' is supported.
Description
Runs the unit tests.
Group
verification
The --test parameter is what you are looking for.
In you case:
gradle test --tests catsRunner
If you want to setup a more comprehensive test filtering, please read the test filtering gradle documentation.

Jasmine maven plugin parsing test result Atlassian Bamboo

So I've managed to get jasmine maven plugin to work with maven and our js unit test.
All is running well, but i found when there's a test that failed, bamboo will say it failed, but the error is "No failed tests found, possible compilation error ocurred".
I've tried to get it to parse TEST-jasmine.xml result by specifically specify the folder JUnit parser needed, and get jasmine to write to that folder using jasmineTargetDir tag in pom.xml, but it's still not finding the right result. Jasmine faithfully write the test result to the folder, but seemingly JUnit is not parsing it?
Any clue as to why and how to solve the issue?
Running on Bamboo v 5.14.3.1 I've configured the Maven task of Default Stage to search for test result files:
And then produced fake failing test. After that the build failed with failing test:
Hope this helps

Fitnesse in Cruisecontrol.net exec: do not fail the build when tests fail

I'm trying to integrate fitnesse with our cruisecontrol setup.
I'd like to have a set of acceptance tests that we develop before the features for the release are worked on. Develop our acceptance tests, run them against our nightly build (not on every check in, we have a job for that but I suspect our acceptance tests would slow that down too much).
So I want to be able to run the fitnesse test suite and not have it fail the build when some tests fail (the expectation is that some of the tests will fail, until we have finished the release).
I have the acceptance tests building on the integration server and the the fitnesse suite running from the command line (as an exec task in the integration job).
At the moment it is failing the build (runner.exe has a non-zero exit code when any test fails).
So... does anyone have a list of exit codes for fitsharp runner.exe? Is there any way to tell a cruisecontrol exec task that I really don't care about the return value from the job? Is there another cc.net task I should use instead?
Edit:
Current best idea is to wrap the fitsharp runner in a batch file or powershell script and swallow the return code from fitness
Edit2:
Return code from fitsharp runner.exe is the number of tests that failed (making setting the success return codes element for the cruisecontrol.net exec task difficult)
I think the best way to do it is with nant, which integrates very nicely with ccnet. You can simply tell a nant exec task to not fail the build, see http://nant.sourceforge.net/release/latest/help/tasks/exec.html
When you're close to release, simply set the failonerror property to true.

Resources