0

Problem statement How to invoke tests within a given test server(i.e. within the process)?

Explanation We know that there is surefire plugin, but this uses surefire:test goal which runs unit tests in separate process. In my case, i need to run the tests within the existing process (pre-configured test server and required environment) to run test. In surefire plugin, there is configuration that has forkCount and reuseForks. If i use it with forkCount as 0, reuseForks true, still creates separate server and hence process. I simply want to avoid setup part for test.

Update after Joe's comment saying it as duplicate As my application usage SpringBoot, running mvn clean install build the project and execute tests. While executing tests, it creates server for each running test. Even though i used configuration given below, in console it shows same process id, but starting server every time. In my case i don't want to make server up for every test case, rather used pre-existing test server and the test should use that server.

Configuration used

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
            <forkCount>0</forkCount>
            <reuseForks>true</reuseForks>
        </configuration>
    </plugin>
Sam
  • 859
  • 3
  • 12
  • 23
  • 1
    Possible duplicate of [Maven surefire plugin fork mode](http://stackoverflow.com/questions/3185850/maven-surefire-plugin-fork-mode) – Joe Aug 30 '16 at 13:08
  • @Joe thank you for the link. Yes some how i need that way, but not sure it will fulfill my whole requirement will do it and update the thread. – Sam Aug 31 '16 at 02:50
  • @Joe What way i can see that making forkcount 0, it usage same process id? – Sam Aug 31 '16 at 17:30
  • Could you please share the code for one of the tests? I'd expect it to share the server instance unless your configuration differs between tests or you use something like @DirtiesContext – Ivan Oct 16 '16 at 13:47

0 Answers0