I have some integration tests that use Selenium and the HtmlUnitDriver to verify my web app behaves correctly from the browser. In IntelliJ, I'm able to run ./gradlew bootRun to start my embedded web server, and then run my Selenium tests manually.
The tests run as expected.
However, I'm wondering what the best strategy is to run these in an automated fashion on my CI Server (TeamCity in this case). Simply running bootRun doesn't quite work since the task runs until it gets terminated.
Should I create a script that runs bootRun, and then I can terminate gradle somehow after the tests complete? I'd also like to use my application.properties file I have in src/test/resources instead of src/main/resources which bootRun uses normally.
Related
I am having a Spring Boot application with around ~500 Tests (Unit and mostly Integration).
When i start running the tests in IntelliJ with second click -> Run all Tests - tests run in around 10-15mins.
When i try to run the tests with "mvn verify -P itest" in IntelliJ terminal, the execution time is around an hour. This is because this command starts and stops the Spring Test Runner Server on every class (which is not my desired result).
The IntelliJ second click -> Run all Tests starts it only once.
Our Jenkins Job is running the tests with "mvn verify -P itest", so my question is how can i change this behavior, to start and stop the Test Runner only once (with this "mvn verify -P itest" command).
itest is the profile that we have in our pom.xml which includes the classes that contain integration tests (using maven failsafe plugin)
Here are the annotations of our base abstract Integration Test class
#RunWith(SpringJUnit4ClassRunner.class)
#SpringBootTest(classes = MainApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
I found this article which could by similar to my problem, but this does not explain the behavior that IntelliJ gives me.
Reset Spring-Boot During Integration Tests
Thanks a lot in advance
I found out why this was happening. There was a setting in my pom file which stated
'reuseForks' maven failsafe property to be false.
I changed it to be true and now it is working fine.
Intellij works in the same way - it is reusing the forks for all the tests.
Read More
http://maven.apache.org/surefire-archives/surefire-2.17/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html
In my spring boot application I have junit test case. I implemented with application listener which will do certain task after server start up. Now I need to run the Junit test case after the bootRun. Basically the application runs like this., I am using gradle build script.
compile->build (running junit test cases)->bootRun
Can we run the test case after bootRun?
Thanks in advance
I have both unit and acceptance tests in a maven project (spring boot). I would like to run unit tests only when my build runs in TeamCity. I am using cucumber.
When i run the tests via command line, everything works as expected (only unit tests are run)
c:\apache-maven-3.3.9\bin\mvn package -Dcucumber.options="--tags #unit"
However, in teamcity, all tests are being run (unit and acceptance). It seems teamcity ignores my cucumber.options
In addition, when I double click on the 'test' lifecycle in Intellij, all tests are run as well (not just unit tests) So my guess is that TeamCity is doing exactly what the 'test' lifecycle does.
How can i get around this problem (in TeamCity)?. I have tried using a 'Command line' step, which works, however, i lose all the tests reporting as well as test coverage reports.
i have solved the Intellij problem by creating (or changing) a configuration:
Try writing it this way in TeamCity:
"-Dcucumber.options= --tags #unit"
As part of my build process, I would like maven to start a program and then execute JUNIT tests in the same phase, which is the mvn test phase.
I am using Spring Boot as well as the Spring Boot Maven plugin. As you know Spring boot has an embedded tomcat container. So I can just run my application on this tomcat server by just running as an application in eclipse.
For example when I run mvn test, I would like my application to run FIRST and then have the tests executed.
I have seen the exec-maven plugin being used and that you specify the phase in the maven build cycle that you want the application to run. The earliest phase that it allows you to specify is the test phase.
But I'm not sure if the Application will run immediately before the tests?
How do I specify in my POM file that I want the application to run BEFORE the test phase?
I have to test a webapp, that is build with maven from Jenkins as CI. The Jenkins instance deploys the webapp via script as 'post build step' to a test enviroment. After the deployment some integration tests should be fired and the results should go back to the jenkins instance.
I can't let maven itself deploy the webapp and utilize surefire/failsafe, because I am not allowed to do so.
I already have a little java app, that uses Selenium WebDriver to perform JUnit tests. I could run this app as 'post build step' like this:
java -cp /usr/share/java/junit.jar junit.textui.TestRunner [test class name]
but I have no ideas how to include dependecies (probably somehow like this: Selenium Scripts on the command line) and how to get the results back to Jenkins.