詳細
推奨事項のタイプ: タイムアウト
設定可能: はい
フィルター カテゴリ例外 / アサーション エラー
説明
この推奨事項は、テスト セットの実行時間が設定された制限時間を超えた場合に表示されます。
サンプルコード
@Test(timeout = 1000)
public void testFactorial() throws Throwable {
// Given
Example underTest = new Example();
// When
int n = 10;
AtomicInteger result = new AtomicInteger();
CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
try {
result.set(underTest.factorial(n));
} catch (Exception e) {
e.printStackTrace();
} finally {
latch.countDown();
}
}
});
latch.await();
// Then
assertEquals(3628800, result.get());
}