We have a suite of JBehave tests which we run on a scheduled job to health check a web service.
On every run, maven downloads dependencies and continues through the rest of its lifecycle before running the tests.
In order to speed up the test execution, is it possible to package the tests within an executable jar along with the associated dependencies and run that instead of using Maven?
Related
How would you run integration test separately after deploy is done.
In jenkins we will build, unit test, run some kind of embedded integration tests.
Then it will deploy to remote server.
How can I run Integration tests against remote deployed server? Running same fail-safe plugin will build the application again. The test will be rest-assured java based tests. How to invoke them without rebuilding the app?
Is the only way to somehow play with profiles? Profile for build and test and profile for black box integration(skiping unit tests and embedded integration test)
Maybe I can bind to maven validate phase, which will skip compilation with profile activating "black-box" fail-safe execution(for validation phase only)
Is it possible to execute a lifecycle target (e.g. integration-test) on an artefact that has been installed within the local repo?
My use case is as follows. I have a multi module project with many modules that dedicated various types of integration testing (compliance test, performance tests, etc). I need to invoke these integration multiple times with different environment configurations. These configurations are expressed as maven profiles and parameterised using properties. I want to avoid recompiling the project over and over again.
I would like to have one build CI job performing the mvn install, then separate CI jobs performing the integration tests, triggered once the build CI job has passed. The integration tests would simply invoke integration-test lifecycle phase of the installed artefact setting the profile and passing the parameters
I have tried pointing mvn at the .pom file within the local repo but this does not work. It fails because it cannot find classes within the artefact's own JAR file (as if it were not being put on the classpath) - a problem that doesn't occur if I have my integration job checkout the tree and invoke the pom.xml within the source tree.
mvn -f ~/.m2/repo/x/y/z/myproj-perftests-x.x.x-SNAPSHOT.pom integration-test -Pmyprofile -Dparam1=blah
No, it is not possible. Maven plugins (normally) only work with project sources.
If your only concern is recompiling project again and again, consider splitting your project into the core part and the integration tests part. Then when running integration tests you'll only need to recompile the integration tests part.
using maven we create a war file and we need to be deployed this war in tomcat(application server) for different environment (DEV/QA/UAT).
We need to run the JUNIT test for each of the environment before deploying.
we have written nearly 60 junit test which need to passed
Is is possible to run the junit test for war file?
if yes how to run all junit test sitting inside the war file
WAR file is deployment artifact that shouldn't include any unit tests. As #Gerold Broser correctly pointed out, Maven handles excluding of unit tests for you if you place them into "src/test/java". Don't ever try to put them into "src/main/java".
we have written nearly 60 junit test which need to passed
Is is possible to run the junit test for war file?
If they are true unit tests, they don't need to be executed against deployed war service. They are testing small chunks of functionality and are generally executed during test phase of maven lifecycle.
If tests are firing requests against deployed server, at that stage they are not unit tests anymore and should be probably placed into separate test project.
Proper place where to run your tests is always Continuous Integration server, so one way or the other make sure that execution is automated! Tests without CI server are waste of time.
BTW
There is maven-tomcat7-plugin to start tomcat and deploy it during interation-test phase of Maven lifecycle, but this maven plugin doesn't seem to be maintained anymore and doesn't work with Servlet 3.0 Java configs and Tomcat 8. So I don't recommend that path.
I have a Gradle custom Test task to run my Integration Tests. I would like to be able to run this without Gradle automatically going through all previous phases and just running the test. Is there a way to do this without -x for each build step?
Currently I have standard structure of project:
src
|---androidTest
|-------------------|---java
|----------------------------|---robotium
|----------------------------|---unit
|---main
|---------|---AndroidManifest.xml
|---------|---java
|---------|---res
According to documentation
I've placed unit and integration tests under androidTest folder.
Since instrumentation tests need lot of time, I placed it inside robotium folder(I use Robotium).
Inside unti - jUnit tests respectively.
To run all tests I invoke ./gradlew connectedCheck - it's taking lot of time.
How to to run integration (inside robotium folder) tests and unit tests separately?
I want to run these tests using gradle - it's for CI server.
For example I want to run integration tests every night and unit tests - every hour..
Thanks!
According to the documentation JUnit tests should be places under - src/test/java and then you'll be able to switch between test sources by changing Test Artifact when selecting Build variants as shown:
(source: android.com)