Will there be a support for Spring Boot dependency injection?
I don’t think there will ever be.
Gatling is not meant to be integrated into a Spring app.
And if you’re trying to get some components loaded in a Spring context because they’re really too complex for you to instantiate with good old constructors, you can also load your BeanFactory
/AppicationContext
yourself and pull the desired components manually.
There are a numerous reasons why one would want/need to have DI framework in their test suite. For us, it is a way to re-use a well working code from other test suites and avoid re-inventing the wheel.
Anyhow, I looked through maven-gatling-plugin to learn how Gatling tests are triggered such as main class and parameters used. It is more-or-less clear to me. Springboot allows defining beans of classes that are not originally Beans themselves. So, the plan is:
- Find the main class and its method that triggers Gatling Simulations
- Find what parameters it expects as inputs
- Create a Bean definition of that class and call the necessary method with params.
Any help with about steps 1 and/or 2 steps would be appreciated!
Here is what I had found:
- MainWithArgsInFile.class is used as entry point for the resultant jar. It, in turn, calls “main” method from “mainClass” using reflection, where “mainClass” is “io.gatling.app.Gatling”.
- main() method calls fromArgs() providing parameters and the rest of Gatling is taking care from here.
As such, is it correct that I just need to create a Bean from “io.gatling.app.Gatling” class and then call its main() method with a list of params, where params are the same ones that we set as System variables(-Dgatling.simulationClass=${classNameHere}).
This makes me think you haven’t understood my previous answer, possibly because you don’t know what BeanFactory and ApplicationContext are.
I really recommend you read Spring’s documentation and try the solution I suggested instead of trying to hack Gatling internals (which won’t work anyway).