有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何访问系统。Jmeter的Java示例中的getProperty()

这就是我想要达到的目标

public class Jmetertest extends AbstractJavaSamplerClient {    

   public void setupTest(JavaSamplerContext context) {    
     TestConfig.load(System.getProperty("configFile"));
      // This configFile has all the properties which I need to run my test
     }
   public void teardownTest(JavaSamplerContext context) {..}
   public SampleResult runTest(JavaSamplerContext context) {    
    // test code
   }
}

我知道我可以使用

public Arguments getDefaultParameters() {..}

但是我想知道,我怎样才能访问jmeter中的System.getProperty();,这样我就可以使用对我来说更方便的东西了


共 (1) 个答案

  1. # 1 楼答案

    您可以这样做:

    public void setUp()
     {
         testFile1 = 
             new File(
                System.getProperty("user.dir") + "/testfiles",
    

    我认为这个链接可以帮助你: java.lang.System.getProperty