私はJunit5でDropwizardAppRuleを交換するにはどうすればよいです

ダビデは回復モニカ言います:

JUnitの4で、私のような何かを行うことができます

@ClassRule
public DropwizardAppRule<Configuration> app = new DropwizardAppRule<>(MyApp.class);

...

app.getLocalPort()

どのように私はJUnitの5でこの動作を再現できますか?この githubの問題、それは私が使用する必要があるように思える@ExtendWith(DropwizardExtensionsSupport.class)が、その不明確方法

アレックスShesterov:

Dropwizard 1.3.0を追加導入することにより、JUnit5サポートをDropwizardExtensionsSupportクラスを

あなたは(何をしている、あなたのテストの開始/終了時にアプリケーションを停止/起動する必要がある場合は具体的には、DropwizardAppRuleありません)、がありますDropwizardAppExtension利用可能に。

JUnit5のために書き直さあなたの例、:

@ExtendWith(DropwizardExtensionsSupport.class)
public class MyTest {

    public static final DropwizardAppExtension<Config> app = new DropwizardAppExtension<>(MyApp.class);

    ...

       // app.getLocalPort() is also available

}

残念ながら、JUnit5のサポートはまだ文書化されていないようです

リンク:

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=225552&siteId=1