Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2012 The Guava Authors
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package com.google.common.testing;
 
 import static org.truth0.Truth.ASSERT;
 
 
 
 import java.util.List;

Unit tests for AbstractPackageSanityTests.

Author(s):
Ben Yu
 
 public class AbstractPackageSanityTestsTest extends TestCase {
 
 
   public void testFindClassesToTest_testClass() {
     .that(findClassesToTest(ImmutableList.of(EmptyTest.class)))
         .isEmpty();
     .that(findClassesToTest(ImmutableList.of(EmptyTests.class)))
         .isEmpty();
     .that(findClassesToTest(ImmutableList.of(EmptyTestCase.class)))
         .isEmpty();
     .that(findClassesToTest(ImmutableList.of(EmptyTestSuite.class)))
         .isEmpty();
   }
 
     .that(findClassesToTest(ImmutableList.of(Foo.class)))
         .has().exactly(Foo.class).inOrder();
     .that(findClassesToTest(ImmutableList.of(Foo.classFoo2Test.class)))
         .has().exactly(Foo.class).inOrder();
   }
 
   public void testFindClassesToTest_publicApiOnly() {
     .that(findClassesToTest(ImmutableList.of(Foo.class)))
         .isEmpty();
     .that(findClassesToTest(ImmutableList.of(PublicFoo.class))).has().item(PublicFoo.class);
   }
 
   public void testFindClassesToTest_ignoreClasses() {
     .ignoreClasses(Predicates.<Object>equalTo(PublicFoo.class));
     .that(findClassesToTest(ImmutableList.of(PublicFoo.class)))
         .isEmpty();
     .that(findClassesToTest(ImmutableList.of(Foo.class))).has().item(Foo.class);
   }
 
     .that(findClassesToTest(ImmutableList.of(Foo.classFooTest.class), "testNotThere"))
         .has().exactly(Foo.class).inOrder();
     .that(findClassesToTest(ImmutableList.of(Foo.classFooTest.class), "testNotPublic"))
         .has().exactly(Foo.class).inOrder();
   }
 
     ImmutableList<Class<? extends Object>> classes = ImmutableList.of(Foo.classFooTest.class);
     .that(findClassesToTest(classes"testPublic"))
         .isEmpty();
     .that(findClassesToTest(classes"testNotThere""testPublic"))
         .isEmpty();
   }
 
     .that(findClassesToTest(ImmutableList.of(Foo.classFooTest.class)))
         .has().exactly(Foo.class).inOrder();
   }
 
   static class EmptyTestCase {}
 
   static class EmptyTest {}
 
   static class EmptyTests {}
 
   static class EmptyTestSuite {}
 
   static class Foo {}
 
  public static class PublicFoo {}
  static class FooTest {
    @SuppressWarnings("unused"// accessed reflectively
    public void testPublic() {}
    @SuppressWarnings("unused"// accessed reflectively
    void testNotPublic() {}
  }
  // Shouldn't be mistaken as Foo's test
  static class Foo2Test {
    @SuppressWarnings("unused"// accessed reflectively
    public void testPublic() {}
  }
  private List<Class<?>> findClassesToTest(
      Iterable<? extends Class<?>> classesString... explicitTestNames) {
    return .findClassesToTest(classes, Arrays.asList(explicitTestNames));
  }
New to GrepCode? Check out our FAQ X