I updated my project to use 2.1.0-SNAPSHOT version because I needed the latest websocket bug fix. Apart from some scala 2.11.4 issues and gatling api changes everything is ok now. I can run my test using sbt gatling:test.
But in the stable version I could use something like this to start the test from intellij:
object CometDGatlingTest extends App {
val gatlingPropertyBuilder = new GatlingPropertiesBuilder
gatlingPropertyBuilder.simulationClass(classOf[CometDGatlingTest].getName)
Gatling.fromMap(gatlingPropertyBuilder.build)
}
class CometDGatlingTest extends Simulation with Logging {
…
}
In the new snapshot version I cannot do this as the api has changed.
What is the best practice now to start a test programmatically with a specific test class?
We’re re-introducing it temporarily to ease maven archetype based projects, but it will be definitively dropped in 2.2.
See deprecation message for migration.
Is it possible that something else has been changed as well?
Exception in thread “main” java.nio.file.NoSuchFileException: ./target/test-classes
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:426)
at java.nio.file.Files.newDirectoryStream(Files.java:413)
I believe that not just the fromMap method changed which is responsible for being able to run the test like an App.
I saw the same exception when I wanted to use the following:
new Gatling(props.build, simulationClass).start
This change comes from the refactoring I made to allow Gatling to upgrade to Scala 2.11.
Gatling search the compiled classes in target/test-classes by default, but in your case, even if this folder does exist, the path is incorrect.
You can, if you want, have a look at how the Maven Archetype fixes this :
But it’ll be faster to simply copy those classes from the archetype into your project and run the Engine class
Side note :
Since you’re using 2.1 snapshots, you may like the fact that the mute mode (not asking for simulationID nor run description) works everywhere, and not only for the SBT plugin.
If you activate it (gatlingPropertyBuilder.mute()), your simulation would now run right away, without asking for inputs. In short, faster development cycles for free
I remembered that there was an Engine and a IDEPathHelper long time ago and I used to use them from gatling 1.5. But since I updated to gatling 2 I couldn’t find them.
Thanks the update.
It has always been there
But when we migrated Gatling from Maven to SBT, the projects necessarily relying on Maven (e.g. our Maven plugin and archetype) were moved to their own repositories, and unified in 2.1 in single gatling-maven repository.
I realized a bit too late that removing ‘fromMap’ was a really bad idea…
On master, there is now ‘fromMap’ and ‘fromArgs’ to start Gatling, and the older ‘runGatling’ is now deprecated.