Пример #1
0
 @Test
 public void testRunWith() throws Exception {
   String specString = "org.pantsbuild.tools.junit.lib.MockRunWithTest";
   SpecParser parser = new SpecParser(ImmutableList.of(specString));
   List<Spec> specs = parser.parse();
   assertEquals(1, specs.size());
   assertEquals(MockRunWithTest.class, specs.get(0).getSpecClass());
 }
Пример #2
0
 @Test
 public void testMissingMethod() {
   String specString = DUMMY_CLASS_NAME + "#doesNotExist";
   SpecParser parser = new SpecParser(ImmutableList.of(specString));
   try {
     parser.parse();
   } catch (SpecException expected) {
     assertThat(expected.getMessage(), containsString("Method doesNotExist not found in class"));
   }
 }
Пример #3
0
 @Test
 public void testMissingClass() {
   String specString = "org.foo.bar.Baz";
   SpecParser parser = new SpecParser(ImmutableList.of(specString));
   try {
     parser.parse();
   } catch (SpecException expected) {
     assertThat(expected.getMessage(), containsString("Class org.foo.bar.Baz not found"));
   }
 }
Пример #4
0
 @Test
 public void testBadSpec() {
   String specString = DUMMY_CLASS_NAME + "#" + DUMMY_METHOD_NAME + "#" + "foo";
   SpecParser parser = new SpecParser(ImmutableList.of(DUMMY_CLASS_NAME, specString));
   try {
     parser.parse();
   } catch (SpecException expected) {
     assertThat(expected.getMessage(), containsString("Expected only one # in spec"));
   }
 }
Пример #5
0
 @Test
 public void testParserClass() throws Exception {
   SpecParser parser = new SpecParser(ImmutableList.of(DUMMY_CLASS_NAME));
   List<Spec> specs = parser.parse();
   assertEquals(1, specs.size());
   Spec spec = specs.get(0);
   assertEquals(UnannotatedTestClass.class, spec.getSpecClass());
   assertEquals(DUMMY_CLASS_NAME, spec.getSpecName());
   assertEquals(0, spec.getMethods().size());
 }
Пример #6
0
 @Test
 public void testParserMethod() throws Exception {
   String specString = DUMMY_CLASS_NAME + "#" + DUMMY_METHOD_NAME;
   SpecParser parser = new SpecParser(ImmutableList.of(specString));
   List<Spec> specs = parser.parse();
   assertEquals(1, specs.size());
   Spec spec = specs.get(0);
   assertEquals(UnannotatedTestClass.class, spec.getSpecClass());
   assertEquals(DUMMY_CLASS_NAME, spec.getSpecName());
   assertEquals(ImmutableList.of(DUMMY_METHOD_NAME), spec.getMethods());
 }
Пример #7
0
 @Test
 public void testMethodDupsClass() throws Exception {
   String specString = DUMMY_CLASS_NAME + "#" + DUMMY_METHOD_NAME;
   SpecParser parser = new SpecParser(ImmutableList.of(DUMMY_CLASS_NAME, specString));
   try {
     parser.parse();
   } catch (SpecException expected) {
     assertThat(
         expected.getMessage(),
         containsString("Request for entire class already requesting individual methods"));
   }
 }
Пример #8
0
 private void assertNoSpecs(String className) throws Exception {
   String specString = "org.pantsbuild.tools.junit.lib." + className;
   SpecParser parser = new SpecParser(ImmutableList.of(specString));
   List<Spec> specs = parser.parse();
   assertTrue(specs.isEmpty());
 }