Search in sources :

Example 1 with TestNode

use of com.google.testing.junit.runner.model.TestNode in project bazel by bazelbuild.

the class JUnit4TestModelBuilderTest method testCreateModel_simpleSuite.

@Test
public void testCreateModel_simpleSuite() throws Exception {
    Class<?> suiteClass = SampleSuite.class;
    Request request = Request.classWithoutSuiteMethod(suiteClass);
    String suiteClassName = suiteClass.getCanonicalName();
    JUnit4TestModelBuilder modelBuilder = builder(request, suiteClassName, stubShardingEnvironment, null, xmlResultWriter);
    Description topSuite = request.getRunner().getDescription();
    Description innerSuite = topSuite.getChildren().get(0);
    Description testOne = innerSuite.getChildren().get(0);
    TestSuiteModel model = modelBuilder.get();
    TestNode topSuiteNode = Iterables.getOnlyElement(model.getTopLevelTestSuites());
    assertEquals(topSuite, topSuiteNode.getDescription());
    TestNode innerSuiteNode = Iterables.getOnlyElement(topSuiteNode.getChildren());
    assertEquals(innerSuite, innerSuiteNode.getDescription());
    TestNode testOneNode = Iterables.getOnlyElement(innerSuiteNode.getChildren());
    assertEquals(testOne, testOneNode.getDescription());
    assertTrue(testOneNode.getChildren().isEmpty());
    assertEquals(1, model.getNumTestCases());
}
Also used : Description(org.junit.runner.Description) TestSuiteModel(com.google.testing.junit.runner.model.TestSuiteModel) Request(org.junit.runner.Request) TestNode(com.google.testing.junit.runner.model.TestNode) Test(org.junit.Test)

Example 2 with TestNode

use of com.google.testing.junit.runner.model.TestNode in project bazel by bazelbuild.

the class JUnit4TestModelBuilderTest method testCreateModel_singleTestClass.

@Test
public void testCreateModel_singleTestClass() throws Exception {
    Class<?> testClass = SampleTestCaseWithTwoTests.class;
    Request request = Request.classWithoutSuiteMethod(testClass);
    String testClassName = testClass.getCanonicalName();
    JUnit4TestModelBuilder modelBuilder = builder(request, testClassName, stubShardingEnvironment, null, xmlResultWriter);
    Description suite = request.getRunner().getDescription();
    Description testOne = suite.getChildren().get(0);
    Description testTwo = suite.getChildren().get(1);
    TestSuiteModel model = modelBuilder.get();
    TestNode suiteNode = Iterables.getOnlyElement(model.getTopLevelTestSuites());
    assertEquals(suite, suiteNode.getDescription());
    List<TestNode> testCases = suiteNode.getChildren();
    assertEquals(2, testCases.size());
    TestNode testOneNode = testCases.get(0);
    TestNode testTwoNode = testCases.get(1);
    assertEquals(testOne, testOneNode.getDescription());
    assertEquals(testTwo, testTwoNode.getDescription());
    assertTrue(testOneNode.getChildren().isEmpty());
    assertTrue(testTwoNode.getChildren().isEmpty());
    assertEquals(2, model.getNumTestCases());
}
Also used : Description(org.junit.runner.Description) TestSuiteModel(com.google.testing.junit.runner.model.TestSuiteModel) Request(org.junit.runner.Request) TestNode(com.google.testing.junit.runner.model.TestNode) Test(org.junit.Test)

Aggregations

TestNode (com.google.testing.junit.runner.model.TestNode)2 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)2 Test (org.junit.Test)2 Description (org.junit.runner.Description)2 Request (org.junit.runner.Request)2