No tests run in maven project with karate module - karate

We have a multi module project with the following structure
module 1
module 2
module e2e
parent pom
The module e2e contains our karate features (into the src/test/java/features folder)
We couldn't figure out how to run the karate tests using the "mvn test".
It always runs 0 tests, instead there are some feature files.
We have tried running "mvn test" from the root of the project, as well as from inside the e2e module
We have other maven projects (not multi module) and it works as expected.
Does it necessary to make some configuration action to do it?
Thanks a lot.

mvn test behind the scenes just looks for JUnit tests, it is that simple. Check that your JUnit class names end with Test - and that the maven tweak for the recommended directory structure is in place: https://github.com/intuit/karate/issues/724
Otherwise unless you follow this process, it is difficult for anyone to help you: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Related

Unable to run tests through commandline [duplicate]

We have a multi module project with the following structure
module 1
module 2
module e2e
parent pom
The module e2e contains our karate features (into the src/test/java/features folder)
We couldn't figure out how to run the karate tests using the "mvn test".
It always runs 0 tests, instead there are some feature files.
We have tried running "mvn test" from the root of the project, as well as from inside the e2e module
We have other maven projects (not multi module) and it works as expected.
Does it necessary to make some configuration action to do it?
Thanks a lot.
mvn test behind the scenes just looks for JUnit tests, it is that simple. Check that your JUnit class names end with Test - and that the maven tweak for the recommended directory structure is in place: https://github.com/intuit/karate/issues/724
Otherwise unless you follow this process, it is difficult for anyone to help you: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

IntelliJ 14 Gradle task in Test Runner

Upgraded to IntelliJ 14.0.1 One of the big new features I was looking for:
"If you run tests via a Gradle task, the IDE offers you the standard Test Runner instead of the console output." (Source: https://www.jetbrains.com/idea/whatsnew/#buildTools)
I right click on the Gradle Task to run our Integration Tests:
However, I see the results of the test still going to console output, not to the Test Runner:
Has anyone been able to get this new feature in IntelliJ IDEA 14 to work?
Thank you in advance,
Philip
Looks like IntelliJ looks for a task named "test" rather than a task of type Test.
https://github.com/JetBrains/intellij-community/blob/master/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/GradleTestsExecutionConsoleManager.java#L191
Rename the test task to unitTest and then create a wrapper that runs both:
// Rename test to unitTest
tasks.test.name = "unitTest"
// Wrap and run both
task test(dependsOn:['unitTest', 'integrationTest'])
If you only want to run integration tests, just overwrite it:
task test(overwrite: true, dependsOn: ['integrationTest'])
This allows me to run the integration tests in the test runner successfully (at least it works in IDEA 15 EAP but it should work in 14 as well I would think).
I still get this in IntelliJ 2017.1, but specifically when running tests in the gradle buildSrc directory. After digging a while, it turns out that the Gradle API doesn’t expose the test tasks in the special buildSrc directory to Intellij, so IntelliJ doesn’t recognize it as a test.
Workaround: Open another IntellIJ project for the buildSrc directory directory instead of trying to run tests cleanly inside the root project.

JaCoCo configuration when sources and tests classes are in different modules

I have a multi-module project with Gradle(2.2) + JaCoCo + Sonar. I'm using the sonar-runner plugin, and when I execute the tests, I can see in each module the test report under build/jacoco/jacoco.exec. So far so good.
The problem is, I have some tests in module A that are testing classes from other module B, and so that JaCoCo is identifying that classes from module B with 0% code-coverage. I know this is not a good practice but it has to be done like that.
Example of the structure:
moduleA
src
java
Foo
test
moduleB
src
java
test
TestFoo
Then JaCoCo will show the class Foo with 0% coverage. I have tried merging the results from all modules but I get the same result but in one single file, so this is not what I'm looking for. Is there any option to include sources from other module when executing the JaCoCo report?
Thanks.
each module need its own tests. Jacoco build each jacoco.exec module after module and cannot go back to a previous one. So you have to set a TestFoo in moduleA.

Run Integration test in toplevel pom

I have a project with 3 modules.I used maven as the build tool.I have Integration test module
Proj/mod1/pom.xml
Proj/mod2/pom.xml
Proj/intTest/pom.xml
Proj/pom.xml
Now I want to run the integration test using top level pom.xml,Is there a way to do that??
Thanxxx
Well, if I get it right the intTest-project does your integration tests and is part of your project Proj so if you run the module build with the appropriate phase (integration-test or verify, depending on what you use) this should be it ...

How can i run maven tests against a previous deployed artifact of the same artifact?

I have an artifact abc which has some tests. I have different versions of abc within my repository. I now want to be able to run the latest tests against the 'old build' of the project.
I tried to add the artifact itself to the test dependencies but this (of course) results in a cyclic reference error of the maven reactor when building the tests via:
mvn compiler:testCompile
mvn surefire:test
Is there any smart way to run tests against a previous old build/artifact?
Must i create a new pom.xml in which i define the solo test execution?
Or should i add a postfix to my current artifact when executing the tests? (This would avoid a cyclic reference error)
Separate the tests out into a separate module/project that depends on the classes it tests. Then create separate profiles where you change the dependency to be on older releases.
The problem I foresee with what you're trying to do is that the package phase comes after the test phase of the maven lifecycle. Which to me implies that maven runs unit tests against the compiled classes and not the physical jar file (generated in the package phase). You'll therefore have to replace the contents of the projects /target/classes folder with the classes in the "older" jar.