| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.common.collect.testing; |
| 18 |
|
| 19 |
import com.google.common.annotations.GwtCompatible; |
| 20 |
import junit.framework.TestCase; |
| 21 |
import org.checkerframework.checker.nullness.qual.Nullable; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
@GwtCompatible |
| 35 |
public class AbstractTester<G> extends TestCase { |
| 36 |
private G subjectGenerator; |
| 37 |
private String suiteName; |
| 38 |
private @Nullable Runnable setUp; |
| 39 |
private @Nullable Runnable tearDown; |
| 40 |
|
| 41 |
|
| 42 |
@Override |
| 43 |
public void setUp() throws Exception { |
| 44 |
if (setUp != null) { |
| 45 |
setUp.run(); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
@Override |
| 51 |
public void tearDown() throws Exception { |
| 52 |
if (tearDown != null) { |
| 53 |
tearDown.run(); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
public final void init( |
| 59 |
G subjectGenerator, String suiteName, @Nullable Runnable setUp, @Nullable Runnable tearDown) { |
| 60 |
this.subjectGenerator = subjectGenerator; |
| 61 |
this.suiteName = suiteName; |
| 62 |
this.setUp = setUp; |
| 63 |
this.tearDown = tearDown; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
public final void init(G subjectGenerator, String suiteName) { |
| 68 |
init(subjectGenerator, suiteName, null, null); |
| 69 |
} |
| 70 |
|
| 71 |
public G getSubjectGenerator() { |
| 72 |
return subjectGenerator; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
public final String getTestMethodName() { |
| 77 |
return super.getName(); |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public String getName() { |
| 82 |
return Platform.format("%s[%s]", super.getName(), suiteName); |
| 83 |
} |
| 84 |
} |