微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何以vertx-junit5方式放置有关RunTestOnContext的vertx @Rule?

如何解决如何以vertx-junit5方式放置有关RunTestOnContext的vertx @Rule?

我想知道是否可以将这种规则(junit)迁移到vertx-junit5方式。 原始示例是github中公共vertx-example存储库中的RunOnContextTest.java。 这是代码

@RunWith(VertxUnitRunner.class)
public class RunOnContextTest {

  /*
   * This rule wraps the junit calls in a Vert.x context,the Vert.x instance can be created by the
   * rule or provided like in this case.
   */
  @Rule
  public final RunTestOnContext rule = new RunTestOnContext(Vertx::vertx);

  private Thread thread;

  @Before
  public void before(TestContext context) {
    context.assertTrue(Context.isOnEventLoopThread());
    thread = Thread.currentThread();
  }

  @Test
  public void theTest(TestContext context) {
    context.assertTrue(Context.isOnEventLoopThread());
    context.assertEquals(thread,Thread.currentThread());
  } 
 @After
  public void after(TestContext context) {
    context.assertTrue(Context.isOnEventLoopThread());
    context.assertEquals(thread,Thread.currentThread());
  }

突出显示的依赖项是:

 <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-unit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。