| 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.collect.testing.features.CollectionFeature; |
| 20 |
import java.util.Collections; |
| 21 |
import java.util.List; |
| 22 |
import junit.framework.Test; |
| 23 |
import junit.framework.TestCase; |
| 24 |
import junit.framework.TestResult; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class FeatureSpecificTestSuiteBuilderTest extends TestCase { |
| 30 |
private static final class MyTestSuiteBuilder |
| 31 |
extends FeatureSpecificTestSuiteBuilder<MyTestSuiteBuilder, String> { |
| 32 |
@Override |
| 33 |
protected List<Class<? extends AbstractTester>> getTesters() { |
| 34 |
return Collections.<Class<? extends AbstractTester>>singletonList(MyTester.class); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
public void testLifecycle() { |
| 39 |
boolean[] setUp = {false}; |
| 40 |
Runnable setUpRunnable = |
| 41 |
new Runnable() { |
| 42 |
@Override |
| 43 |
public void run() { |
| 44 |
setUp[0] = true; |
| 45 |
} |
| 46 |
}; |
| 47 |
|
| 48 |
boolean[] tearDown = {false}; |
| 49 |
Runnable tearDownRunnable = |
| 50 |
new Runnable() { |
| 51 |
@Override |
| 52 |
public void run() { |
| 53 |
tearDown[0] = true; |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
MyTestSuiteBuilder builder = new MyTestSuiteBuilder(); |
| 58 |
Test test = |
| 59 |
builder |
| 60 |
.usingGenerator("yam") |
| 61 |
.named("yam") |
| 62 |
.withFeatures(CollectionFeature.NONE) |
| 63 |
.withSetUp(setUpRunnable) |
| 64 |
.withTearDown(tearDownRunnable) |
| 65 |
.createTestSuite(); |
| 66 |
TestResult result = new TestResult(); |
| 67 |
int timesMyTesterWasRunBeforeSuite = MyTester.timesTestClassWasRun; |
| 68 |
test.run(result); |
| 69 |
assertEquals(timesMyTesterWasRunBeforeSuite + 1, MyTester.timesTestClassWasRun); |
| 70 |
assertTrue(setUp[0]); |
| 71 |
assertTrue(tearDown[0]); |
| 72 |
} |
| 73 |
} |