Rest Api load tesing Zerocode tdd giving error message

前提是你 提交于 2021-02-10 16:44:10

问题


I'm automating my rest api and searching for a performance testing framework to use with my junit5. I came across zerocode tdd but it is not helping it's giving error and all the tests are falling under failure. My test method is proper and works when it invoked normally by junit jupiter. When I use zerocodeLoadRunner for the same thing it is not working.

    import org.jsmart.zerocode.core.domain.LoadWith;
    import org.jsmart.zerocode.core.domain.TestMapping;
    import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;   
    import org.junit.runner.RunWith;

    @LoadWith("loadConfig.properties")

    @TestMapping(testClass = MyTest.class, testMethod = "myMethod")

    @RunWith(ZeroCodeLoadRunner.class)

    public class LoadTest  {

    }

The error message I am getting is as follows.

    2019-09-09 12:35:57,191 [main] ERROR org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner - myPackage.LoadTest.myMethod Failed. See target/logs -or- junit granular failure report(csv) -or- fuzzy search and filter report(html) for details

The dependency used for this is as follows

    <dependency>
        <groupId>org.jsmart</groupId>
        <artifactId>zerocode-tdd-jupiter</artifactId>
        <version>1.3.8</version>
    </dependency>

I don't want to use any testing tool so I'm going with this.


回答1:


The setup which you have done works for JUnit4(but not for JUnit5 as JUnit5 does not support Runners). For JUnit5, you need to use the following extention of zerocode.

@ExtendWith({ParallelLoadExtension.class})

This JUnit5-Jupiter-Parallel-Load-Extension page has the precise details. Please try the below way:

e.g.

@LoadWith("load_generation.properties")
@ExtendWith({ParallelLoadExtension.class})
public class JUnit5LoadCommonLoadTest {

    @Test
    @DisplayName("testing parallel load for X, Y and Z scenarios")
    @TestMappings({
            @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
            @TestMapping(testClass = JUnit5Test.class, testMethod = "testY"),
            @TestMapping(testClass = JUnit5MoreTest.class, testMethod = "testZ")
    })
    public void testLoad_xyz() {
        // This space remains empty
    }
}

You can visit this Github JUnit5 Load examples for JUnit5 Jupiter load tests and also how to run them via JUnit5 Suite.




回答2:


I second the answer above the issue is you are setup using JUnit4 style tests and need to setup for JUnit5 - I have tested this as recently as the last few weeks and works exactly as specified above.

One item to note is that in the properties file I have found you need to set seconds 15-20% higher than threads (ie threads 20 / seconds 25). If you do not then I very commonly see failures in the zerocode test



来源:https://stackoverflow.com/questions/57849469/rest-api-load-tesing-zerocode-tdd-giving-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!