Build executable JAR for Gatling load test

后端 未结 6 1156
感动是毒
感动是毒 2020-12-30 02:01

I am new to Gatling (2.1.2) and want to do a small prototype project to show to my colleagues.

According to the quick start page, there are several ways I can run a

6条回答
  •  一向
    一向 (楼主)
    2020-12-30 03:06

    You can always create a simple Java class that starts Gatling with the Gatling.fromArgs. With this setup you can have all in just one happy executable jar. Let this class be the jar mainClass instead of "io.gatling.app.Gatling". This example is for a scala simulation class "my.package.MySimulation".

    import scala.Option;
    import io.gatling.app.Gatling;
    import io.gatling.core.scenario.Simulation;
    
    public class StartSimulation {
    
      public static void main(String[] args) {
        Gatling.fromArgs(new String[]{}, new Option>() {
    
            private static final long serialVersionUID = 1L;
    
            @Override
            public int productArity() {
                return 0;
            }
    
            @Override
            public Object productElement(int arg0) {
                return null;
            }
    
            @SuppressWarnings("unchecked")
            @Override
            public Class get() {
                try {
                    return (Class) Class.forName("my.package.MySimulation");
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
                return null;
            }
    
            @Override
            public boolean isEmpty() {
                return false;
            }
    
            @Override
            public boolean canEqual(Object o) {
                return false;
            }
        });
      }
    }
    

提交回复
热议问题