-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
TestLifecycleAwareContainerMock.java
42 lines (32 loc) · 1.26 KB
/
TestLifecycleAwareContainerMock.java
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
package org.testcontainers.spock;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.lifecycle.TestDescription;
import org.testcontainers.lifecycle.TestLifecycleAware;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class TestLifecycleAwareContainerMock extends GenericContainer<TestLifecycleAwareContainerMock> implements TestLifecycleAware {
static final String BEFORE_TEST = "beforeTest";
static final String AFTER_TEST = "afterTest";
final List<String> lifecycleMethodCalls = new ArrayList<>();
final List<String> lifecycleFilesystemFriendlyNames = new ArrayList<>();
Throwable capturedThrowable;
@Override
public void beforeTest(TestDescription description) {
lifecycleMethodCalls.add(BEFORE_TEST);
lifecycleFilesystemFriendlyNames.add(description.getFilesystemFriendlyName());
}
@Override
public void afterTest(TestDescription description, Optional<Throwable> throwable) {
lifecycleMethodCalls.add(AFTER_TEST);
throwable.ifPresent(capturedThrowable -> this.capturedThrowable = capturedThrowable);
}
@Override
public void start() {
// Do nothing
}
@Override
public void stop() {
// Do nothing
}
}