Annotations Flashcards

1
Q

@ParameterizedTest

A

These tests make it possible to run a test multiple times with different arguments.

In addition, you must declare at least one source that will provide the arguments for each invocation and then consume the arguments in the test method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

@ParameterizedTest - visual

A

@ParameterizedTest
@ValueSource(strings = { “racecar”, “radar”, “able was I ere I saw elba” })
void palindromes(String candidate) {
assertTrue(StringUtils.isPalindrome(candidate));
}

palindromes(String) ✔
├─ [1] candidate=racecar ✔
├─ [2] candidate=radar ✔
└─ [3] candidate=able was I ere I saw elba ✔

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

@ValueSource

A

It’s one of the simplest possible sources. It lets you specify a single array of literal values and can only be used for providing a single argument per parameterized test invocation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

@Disabled

A

Used to disable a test class or test method; analogous to JUnit 4’s @Ignore. Such annotations are not inherited.

@Disabled(“Disabled until bug #99 has been fixed”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

@Timeout

A

allows one to declare that a test, test factory, test template, or lifecycle method should fail if its execution time exceeds a given duration.

@Test
@______(value = 500, unit = TimeUnit.MILLISECONDS, threadMode = ThreadMode.SEPARATE_THREAD)
void failsIfExecutionTimeExceeds500MillisecondsInSeparateThread() {
// fails if execution time exceeds 500 milliseconds, the test code is executed in a separate thread
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly