Details

Recommendation type: Exceptions and assertion errors

Configurable: No

Filter category: Exceptions / assertion errors

Description

UTA displays this recommendation when a test fails during execution, or an exception is thrown.

Example

@Test
public void testFactorial2() throws Throwable {
    // Given
    Example underTest = new Example();

    // When
    int n = 5;

    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(10, TimeUnit.MICROSECONDS);

    // Then
    assertEquals(120, result.get());
}

  • No labels