Migration from sbt to maven

275 views
Skip to first unread message

John Arrowwood

unread,
Feb 10, 2022, 5:21:49 PM2/10/22
to Gatling User Group
The current project has 
* common code in src/main, 
* unit tests of that code in src/test, 
* and all the gatling integration tests in src/it.

What will be the process for finding, compiling and running those tests in the `it` folder?  Or am I going to have to migrate the folder structure?

Stéphane LANDELLE

unread,
Feb 11, 2022, 3:17:00 AM2/11/22
to gat...@googlegroups.com
maven doesn't have the notion of "configurations" like gradle and sbt have.

Do your Gatling tests have any dependency to your main and test code? Does it need to live in the same lifecycle?

If Gatling tests are isolated, IMHO, the best solutions are:
  • either move your Gatling tests into a subdirectory so they are completely isolated from your application code. This way, you have Gatling live in the same git repository and yet don't risk mixing/messing up with your application's classpath
  • or isolate Gatling execution into a profile where you remap the test directories:

<profiles>
  <profile>
    <id>gatling</id>
    <build>
      <testSourceDirectory>src/it/scala</testSourceDirectory>
      <testResources>
        <testResource>
          <directory>${project.basedir}/src/it/resources</directory>
        </testResource>
      </testResources>
    </build>
  </profile>
</profiles>


--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/803b43dd-0425-4b9e-b83b-1aa5967221cbn%40googlegroups.com.

John Arrowwood

unread,
Feb 11, 2022, 2:30:11 PM2/11/22
to Gatling User Group
The entire code base is test code only.  No application code.

The code in src/main is stuff like the API abstraction layer, a bunch of code that makes the tests themselves more concise to write.  I only put tests in src/it because that was the standard practice for an SBT based project at the time that I first started working on it.

I could move everything into src/main.  Would doing so have any unintended consequences for me?  Like, would that hurt our ability to use FrontLine again ?

Stéphane LANDELLE

unread,
Feb 13, 2022, 5:36:18 PM2/13/22
to gat...@googlegroups.com
You can try something like this:

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>add-integration-test-sources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/it/scala</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-integration-test-resources</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>src/it/resources</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>${scala-maven-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <jvmArgs>
                <jvmArg>-Xss100M</jvmArg>
              </jvmArgs>
              <args>
                <arg>-target:jvm-1.8</arg>
                <arg>-deprecation</arg>
                <arg>-feature</arg>
                <arg>-unchecked</arg>
                <arg>-language:implicitConversions</arg>
                <arg>-language:postfixOps</arg>
              </args>
            </configuration>
          </execution>
        </executions>
      </plugin>

However, please note that as maven actually only has main and test config, your unit tests and unit tests framework will be shipped in the Gatling Enterprise package.


--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 

Reply all
Reply to author
Forward
0 new messages