I am developing in not common language (IBM SQL PL) and I want to integrate the unit system framework of that language into the lifecycle of Maven.
I would like to know how the command maven test works. It seems that the normal execution is only for Java, because the three SurefireProviders are jUnit3, jUnit4 and TestNG. The SurefireProvider documentation does not explain nor gives indications about other providers for different programming languages.
I can also configure the execution of my programming language tests into the test phase, but I do not know the side effects. This is explained here: https://stackoverflow.com/a/19356216/456274
In conclusion, what is the best way to integrate unit test report into maven test execution and be part of the lifecycle to include that into a continuous integration?
There are similar and more common issues for developers who want to test their javascript code with maven.
You should write your own maven plugin which integrates your unit testing framework to maven lifecycle: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
A good example is the Jasmine Maven Plugin which integrate jasmine, a unit testing framework for javascript: http://searls.github.io/jasmine-maven-plugin/
Then, by adding your custom maven plugin in test goal, your "mvn test" command will invoke it.
Related
Our application is spring boot based project written with kotlin. There is great plugin for JetBrains IntelliJ IDEA for Allure support. The plugin provide a possibility to generate test reports, upload them to Allure TestOps and link tests from source code to test launch (tree of all tests) in Allure TestOps. Linking is achieved through adding #AllureId annotation to tests in source code.
My goal is automate this process inside build pipelines. Allure has allurectl tool which allows to upload test reports to Allure TestOps. But as far as I concerned it doesn't have a feature to assign #AllureId annotations.
Is there any option to assign #AllureId to tests from source code using command line?
You are generally right - allurectl does not have this feature. It is supported in the Allure IDEA plugin only.
The reason is that automated test-case linking feature in the plugin is implemented via the IntelliJ engine, so we'd have to write our own engine for the allurectl to make it work.
I've find out that adding a label's node with name "as_id" to generated json report works as a way to set allureId. Tested with upload to Allure TestOps, it works.
Some details are here and in related PR:https://github.com/Tinkoff/Allure.XUnit/issues/25
Is there a way to run Karate test during maven's integration test phase? It seems that surefire plugin is hardcoded into Karate. I have tried to override it using failsafe plugin but with no luck. I don't want test to run along with unit tests.
Thank in advance!
It seems that surefire plugin is hardcoded into Karate
I'm not sure where you got that impression, but no, the surefire plugin is not hardcoded into Karate.
Keep in mind that the simplest way to not run a JUnit test via surefire is to not use the *Test.java naming convention.
I think the solution for you is simple, whichever JUnit test is the "entry-point" for your Karate tests (the parallel runner is recommended) - just use the failsafe naming conventions.
And then, just include the failsafe plugin as per the examples and it should work. If you have trouble getting that to work (unlikely), then you should look at maven profiles.
EDIT: also see this comment: Is there a way to run Karate tests as an integration test suite against a pre-booted spring boot server?
Turns out that I cannot be done and it is a limitation of Maven, not Karate. Howto add another test source folder to Maven and compile it to a separate folder? - Here is my test project to prove it out: https://github.com/djangofan/spring-boot-hello - Thanks for leading me down what appears to have been the correct path to discover the limitation. Using Gradle would likely solve my issue but that is not an option on my project. If I use Karate for "separated integration tests", I need a separate mvn test module.
I have inherited a framework that uses Cucumber to use a series of browser-based tests with Selenium, in Java. The framework is currently built using Gradle and this works well.
I would very much like to integrate this whole thing with Browserstack, but the only Gradle plugin that I can find (here) is for Espresso, and so not applicable to my issue. I have also found another repository (here) which does exactly what I want, but does so through Maven.
Note I am unfamiliar with both Gradle and Maven and hence am inclined to stick with the solution that is currently running and wary of unnecessary change. Bearing this in mind, I have the following questions:
Is there a published way to integrate Cucumber (Java) with Browserstack using Gradle?
If not, is converting from Gradle to Maven really as trivial as this article makes me believe? Is there anything else I must be aware of?
Regarding your queries:
1- I am not aware of any published documentation to integrate Cucumber (Java) with Browserstack using Gradle
2- In the link that you have shared( https://dzone.com/articles/how-to-convert-maven-to-gradle-and-vice-versa), it says that you can convert maven to gradle in one step.
Run the command:
gradle init
In the directory containing the POM. This will convert the Maven build to a Gradle build, generating a settings.gradle file and one or more build.gradle files.
3-You have also shared the link: https://github.com/browserstack/cucumber-java-browserstack which uses maven.
You can follow the steps and easily convert maven to gradle
I wanted to get code coverage of regression tests,which tests java webserver endpoints.
Things I have
1. I am having jar file of source
2. Regression code written using TestNG framework.
So here, I will run this jar file to run webserver and then I will run my regression code which will test running webserver.Here I wanted to get code coverage report of Regression tests.Can anyone give any suggestion ?
You can use EMMA(A free code coverage tool). If you are using eclipse you can directly get it from market place. Also it supports running individual Java class file or jar file. Here is the link for more information.
http://emma.sourceforge.net/intro.html
If you're using Maven, you can have a look at qualinsight-maven-cobertura-mojo. There is a companion Github project that provides examples showing how to use it along with jetty (versions 7.6.x, 8.1.x, 9.2.x, 9.3.x). In the exmaples JUnit is being used, but it has no impact at all on the result, you can use TestNG if you want to.
The example shows how to use this Maven plugin and configure your project in order to:
Instrument your code for coverage with qualinsight-maven-mojo-core
run your Jetty server and deploy instrumented code
run your tests (you'll have to replace Junit tests by TestNG ones, and make sure they are run during the integration-test phase)
stop your Jetty server (this will dump coverage file to disk)
Generate coverage report
If needed coverage reports can then be imported in SonarQube using the Generic Coverage plugin (see documentation.)
Note that this plugin has some advantages and limitations compared to cobertura-maven-plugin (see its documentation), but given the description of your requirements, none of the limitations seems to be a blocker in your context.
I would like to make a separate project for my integration tests.
My current structure is like this (Maven project):
my-project-parent
my-project-lib (jar)
my-project-web (war)
Inside the lib sub project is the logic of my project. Inside the web sub project is everything that is related to my Servlets. There is still a lot of logic in there that makes it possible to handle all the different requests.
The sub projects have unit tests. Now the unit tests and integration tests are scrambled in the project and it’s hard to see if it is a unit test or an integration test. By putting the integration tests in a separate project it also makes it possible to manage whether to run the integration tests.
Because of this I would like to create another sub project with all the integration test (my-project-it).
So far I have a separate project called “my-project-it”. I can do some test on the lib sub project. The problem I ran in to was that I needed a lot of classes from my-project-web. I’m unable/not willing to put the war as a dependency.
Can anyone help me with this?
There is an (old but) good wiki article about integration testing with maven.
I personally prefere a separate module that contains all the integration tests in src/it/java. This module can be activated with a maven build profile. The tests are run and the results verified with the failsafe plugin.
hth,
- martin
I would move all classes that are needed for my-project-it from my-project-web to my-project-jar and made it my-project-it's dependency.
Another option is instead of creating a separate my-project-it project create a separate package for integration tests under src/test/java and execute them with maven-failsafe-plugin http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html