Unable to execute single runner class from gradle command line - gradle

I am trying to call specific runner class from command line argument from command line using gradle, however by default all the runner class is getting executed,
gradle test -Dtest=testRunner
however this behaviour is not replicated when executed with maven build tool

Related

How to run maven command line tests in Intellij to resolve testSuiteXmlFiles0 has null value ERROR

I have a maven project which can be run from command line (in IntelliJ). Yet, when I try to in the UI, I get the following error.
testSuiteXmlFiles0 has null value
Attached is the screenshot of error and maven runtime configuration. Again, the command line (in the runtime configuration) works fine from command line.
mvn clean test -Dsurefire.suiteXmlFile=src/test/resources/legacy/bddsSmoke.xml -Dbrowser=chrome -Denvironment=sit03

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.

Gradle - Corda flow tests fail when run from the command line

In my project I have a module that contains Corda flow tests written in Kotlin, and using JUnit. Most of the tests pass, except for the flow tests
My assumption is that this is because Corda flow tests require -ea -javaagent:lib/quasar.jar in the command line...
In my gradle.build file I've added
test {
jvmArgs "-ea -javaagent:lib/quasar.jar"
}
And then from the command line I'm running ./gradlew test but I get these errors from the flow tests:
java.lang.IllegalStateException
kotlin.UninitializedPropertyAccessException
Further Investigations
Running ./gradlew test --info suggests that the jvm arguments are being ignored altogether:
com.acme.FlowTests > Issuance flow should be signed by the initiator FAILED
java.lang.IllegalStateException: Missing the '-javaagent' JVM argument. Make sure you run the tests with the Quasar java agent attached to your JVM. See https://docs.corda.net/troubleshooting.html - 'Fiber classes not instrumented' for more details.
kotlin.UninitializedPropertyAccessException: lateinit property network has not been initialized
The problem was that I was specifying jvmArgs in the wrong module. Adding the following line to gradle.build of the module that contains the tests fixed the issue:
test.jvmArgs = ["-ea", "-javaagent:../lib/quasar.jar"]

Run maven cucumber tests from IntelliJ

I have a maven project, which run cucumber tests using JUnit runner. I can use the following syntax from command line to run the tests:
mvn -Dcucumber.options="--tags #Sanity" test
This works perfectly fine when run from the console. Now I'm trying to set up Maven runner configuration in IntelliJ IDEA to do the same - and I just can't get it to work. According to the IntelliJ documentation, I need to \-escape double quotes - so in the command line I specify -Dcucumber.options=\'--tags #Sanity\' test
Maven is executed - but produces this error message:
Unknown lifecycle phase "#Sanity""
It appears that the parameter is unescaped before being passed to maven. I then tried to putting the entire thing in quotes, specifying parameters as '-Dcucumber.options=\"--tags #Sanity\"' test. This results in the following error:
Unknown lifecycle phase "'-Dcucumber.options="--tags"
Again, I guess, something is with quoting/escaping. I then tried these options: "-Dcucumber.options='--tags #Sanity'" test - this time maven goes through the compilation stage and seemingly attempts to run tests - but then fails with the following error:
Tests in error:
initializationError(com.mycompany.mypackage.MyRunner): Unknown option: --tags #Sanity
I tried all sorts of quoting/escaping/double-escaping/double-quoting/etc. - to no avail.
Again, running maven from command line works fine - I am specifically interested in setting it up as a runner configuration in IntelliJ IDEA.
You need to escape space character: mvn "-Dcucumber.options=--tags\ #Sanity" test

Resources