-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathTestSandbox.java
More file actions
74 lines (65 loc) · 2.27 KB
/
TestSandbox.java
File metadata and controls
74 lines (65 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.typesafe.config.Config;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.RepeatedTest;
import org.powertester.annotations.FailingTest;
import org.powertester.annotations.FlakyTest;
import org.powertester.annotations.SmokeTest;
import org.powertester.config.TestEnvFactory;
import setup.TestSetup;
@Slf4j
public class TestSandbox extends TestSetup {
@RepeatedTest(10)
void assertThatWeCanGetUserConfig() {
final Config CONFIG = TestEnvFactory.getInstance().getConfig();
final String expectedEnv = CONFIG.getString("TEST_ENV");
assertAll(
"Config test",
() -> assertEquals(expectedEnv, CONFIG.getString("TEST_ENV"), "TEST_ENV"),
() ->
assertEquals(
"/employee/create",
CONFIG.getString("CREATE_EMPLOYEE_ENDPOINT"),
"CREATE_EMPLOYEE_ENDPOINT"),
() ->
assertEquals(
expectedEnv.toLowerCase() + "-admin-user",
CONFIG.getString("ADMIN_NAME"),
"ADMIN_NAME"),
() -> assertFalse(CONFIG.getBoolean("TOGGLE"), "TOGGLE"),
() -> assertEquals(10, CONFIG.getInt("NR_OF_USERS"), "NR_OF_USERS"),
() -> assertEquals(123.456, CONFIG.getDouble("PRICE"), "PRICE"),
() ->
assertEquals(
expectedEnv.toLowerCase() + "-user", CONFIG.getString("USER_NAME"), "USER_NAME"));
}
/** a very basic test */
@SmokeTest
void assertThatTrueIsTrue() {
assertTrue(true, "true is true");
}
@FailingTest
void assertThatADayIsADay() {
assertEquals("day", "night", "true is true");
}
@DisplayName("flaky test")
@FlakyTest
void createAFlakyTestCase() {
long currentTimeStamp = System.currentTimeMillis();
log.debug("currentTimeStamp: {}", currentTimeStamp);
if (currentTimeStamp % 2 == 0) {
assertTrue(true, "time is even");
} else {
assertTrue(false, "time is odd");
}
}
@SmokeTest
void
assertThatTrueIsTrue2() {
assertTrue(true, "true is true");
}
}