热门手机游戏秘籍攻略应用教程大全

本篇文章给人人带来的内容是关于PHP框架中MVC架构的剖析(附示例),有肯定的参考价值,有须要的朋侪能够参考一下,愿望对你有所协助。

junit是没法举行并发测试,然则又有须要并发测试的场景怎么办呢?此时能够借助一个插件(Groboutils Core)来完成这类功用。
maven堆栈地点:点我直达

完成

第一步:在项目的pom.xml中到场依靠

<!-- https://mvnrepository.com/artifact/net.sourceforge.groboutils/groboutils-core -->
<dependency>
  <groupId>net.sourceforge.groboutils</groupId>
  <artifactId>groboutils-core</artifactId>
  <version>5</version>
  <scope>test</scope>
</dependency>

第二步:在单测中举行代码编写

@Test
  public void testConcurrentInitOrBind() {

    // mock一个返回
    doReturn(Lists.newArrayList(userMemberCard)).when(operateCardDao)
        .queryCardByRegisterMobileAndTenantId(anyString(), anyLong());

    TestRunnable runner = new TestRunnable() {
      // 在runTest要领中填写本身的测试要领
      @Override
      public void runTest() throws Throwable {
        InitCardResVo resVoFirst = operateCardService.initOrBindCard(requestVo);
        System.out.println("result resVoFirst is:" + resVoFirst.toString());
      }
    };

    // 一个数组,代表并发个数。此处并发5个
    TestRunnable[] trs = new TestRunnable[5];
    for (int i = 0; i < 5; i++) {
      trs[i] = runner;
    }
    MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
    try {
      mttr.runTestRunnables();
    } catch (Throwable ex) {
      ex.printStackTrace();
    }
  }

以上就是Junit借助Groboutils Core举行并发测试的完成要领(细致步骤)的细致内容,更多请关注ki4网别的相干文章!

赞(0) 打赏

上一篇:

下一篇:

相关推荐

0 条评论关于"Junit借助Groboutils Core举行并发测试的完成要领(细致步骤)【JAVA教程】,java,单元测试,junit"

表情

最新评论

    暂无留言哦~~

支付宝扫一扫打赏

微信扫一扫打赏


Warning: error_log(/www/wwwroot/soxunxi.cn/wp-content/plugins/spider-analyser/#log/log-0919.txt): failed to open stream: No such file or directory in /www/wwwroot/soxunxi.cn/wp-content/plugins/spider-analyser/spider.class.php on line 2900