Build successful but not executing tagged junit test cases using gradle command - gradle

I'm using below gradle command to run test cases :-
./gradlew integrationTest -Ptag=regression

Related

Gradle Wrapper compile and build code and run a single unit test

Hey guys I am having a little trouble with the gradle wrapper.
Is there any good way to compile all my code, compile all my tests, and run a single test.
This is for a scripting command in a Jenkins pipeline.
I have used
./gradlew build, which runs all the tests
./gradlew build -x test, which compiles all main code and not allow me to run any tests
Thanks for any help
see the gradle documentation https://docs.gradle.org/current/userguide/java_testing.html#test_filtering
# Executes all tests in SomeTestClass
gradle test --tests SomeTestClass
# Executes a single specified test in SomeTestClass
gradle test --tests SomeTestClass.someSpecificMethod
gradle test --tests SomeTestClass.*someMethod*
# specific class
gradle test --tests org.gradle.SomeTestClass
# specific class and method
gradle test --tests org.gradle.SomeTestClass.someSpecificMethod

How to skip test task when running sonarqube task?

When I execute sonarqube task, by default test task runs. How can I configure Gradle to not run tests when I specifically run sonarqube.
I want to configure this build.gradle.kts.
When I run
./gradlew sonarqube -x test
then tests are not executed.
I want to achieve the same by configuring in the build.gradle.kts file.

How to skip cucumber tests during build & deployment when unit test runs but after deployment it should run cucumber tests via Jenkins - Maven

I have a build project in which i implemented Cucumber BDD and wrote features file and test classes. Now, what i want is that during build & deployment in Jenkins pipeline, all Unit tests should get executed but not the Cucumber tests i.e. Integration tests. As soon as deployment is completed then these cucumber tests should get executed. How we can achieve that?
Is there any way to skip cucumber test during the deployment but after the deployment completion it should execute them?
You can tag your tests with annotations as #Deploy and #AfterDeploy,
To maven deployment script, you can add following script :
-Dcucumber.options="--tags #Deploy"
For the tests after deployment you can use following :
-Dcucumber.options="--tags #AfterDeploy"

How to run multiple cucumber runners from maven command line

I've 2 CI flows , which flow needs to run it's own cucumber runner
RunnerATest
RunnerBTest
I'm using maven command line to run the tests (mvn test)
Is there a way to select a specific Runner from command line ?
Thanks
Maven Surefire Plugin - Running a Single Test
During development, you may run a single test class repeatedly. To run this through Maven, set the test property to a specific test case.
mvn -Dtest=TestCircle test
So you'd do just that. mvn -Dtest=RunnerATest test.

How to run only specific tests with Gradle and JUnit 5?

Using Gradle and its JUnit 4 support, I can choose a specific test using the --tests option like this:
$ ./gradlew test --tests de.mp.BarMT
This option is ineffective when using the JUnit 5 Gradle task. It is ignored silently when using the test tasks from the command line. The true work is done by junitPlatformTest anyway, and it does not support the option:
$ ./gradlew clean junitPlatformTest --tests de.mp.BarMT
…
Problem configuring task :junitPlatformTest from command line.
> Unknown command-line option '--tests'.
Does the JUnit 5 plugin support choosing specific tests?
Answering myself… A lot of time has passed, new versions came, and I can confirm that with Gradle 5.4.1 and JUnit Jupiter Platform 1.4.2, the simple configuration:
test {
useJUnitPlatform()
}
will allow running single tests as seen in https://stackoverflow.com/a/31468902/2621917, even when using weird names (from Kotlin):
gradle test --tests 'HtmlForwardInterceptorTest.should forward requests'

Resources