Merge pull request #9948 from meysam/master
BAEL-4336 @BeforeAll and @AfterAll Methods as a non-static
This commit is contained in:
commit
ed8b77a375
@ -0,0 +1,27 @@
|
||||
package com.baeldung.junit5.nonstatic;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class BeforeAndAfterAnnotationsUnitTest {
|
||||
|
||||
String input;
|
||||
Long result;
|
||||
|
||||
@BeforeAll
|
||||
public void setup() {
|
||||
input = "77";
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public void teardown() {
|
||||
input = null;
|
||||
result = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenConvertStringToLong_thenResultShouldBeLong() {
|
||||
result = Long.valueOf(input);
|
||||
Assertions.assertEquals(77l, result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user