Java Code Examples for org.junit.runner.Description#createTestDescription()
The following examples show how to use
org.junit.runner.Description#createTestDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JUnit4RunnerTest.java From bazel with Apache License 2.0 | 6 votes |
@Test public void testFilteringAndShardingTogetherIsSupported() { config = createConfig("testThatAlways(Passes|Fails)"); shardingEnvironment = mock(ShardingEnvironment.class); shardingFilters = new FakeShardingFilters( Description.createTestDescription(SamplePassingTest.class, "testThatAlwaysPasses"), Description.createTestDescription(SampleFailingTest.class, "testThatAlwaysFails")); when(shardingEnvironment.isShardingEnabled()).thenReturn(true); JUnit4Runner runner = createRunner(SampleSuite.class); Result result = runner.run(); verify(shardingEnvironment).touchShardFile(); assertThat(result.getRunCount()).isEqualTo(2); assertThat(result.getFailureCount()).isEqualTo(1); assertThat(result.getIgnoreCount()).isEqualTo(0); assertThat(result.getFailures().get(0).getDescription()) .isEqualTo( Description.createTestDescription(SampleFailingTest.class, "testThatAlwaysFails")); }
Example 2
Source File: ScriptRunner.java From purplejs with Apache License 2.0 | 6 votes |
@Override public Description getDescription() { final Description suite = Description.createSuiteDescription( this.testClass ); for ( final ScriptTestInstance file : this.testFiles ) { final Description desc = Description.createTestDescription( file.getName(), file.getName() ); suite.addChild( desc ); for ( final ScriptTestMethod method : file.getTestMethods() ) { final Description methodDesc = Description.createTestDescription( file.getName(), method.getName() ); desc.addChild( methodDesc ); } } return suite; }
Example 3
Source File: SuiteAssignmentPrinterTest.java From android-test with Apache License 2.0 | 6 votes |
@Test public void methodIsAssignedToWrongSuite_sendSuiteSuggestion() throws Exception { Description description = Description.createTestDescription( SampleTestClassWithSizeAnnotations.class, "mediumSizeTest", SampleTestClassWithSizeAnnotations.class.getMethod("mediumSizeTest").getAnnotations()); // Don't output anything in instrumentation status doNothing().when(suiteAssignmentPrinter).sendStatus(anyInt(), any(Bundle.class)); // Set end time when(suiteAssignmentPrinter.getCurrentTimeMillis()).thenReturn(100L); // Set time for small test bucket suiteAssignmentPrinter.timingValid = true; suiteAssignmentPrinter.startTime = 50L; suiteAssignmentPrinter.testFinished(description); verify(suiteAssignmentPrinter).sendString(contains("suggested: small")); }
Example 4
Source File: TestUtils.java From video-recorder-java with MIT License | 5 votes |
public static void runRule(TestRule rule, Object target, String methodName) { Class<?> clazz = target.getClass(); Method method = TestUtils.getMethod(clazz, methodName); Description description = Description.createTestDescription(clazz, method.getName(), method.getDeclaredAnnotations()); try { InvokeMethod invokeMethod = new InvokeMethod(new FrameworkMethod(method), target); rule.apply(invokeMethod, description).evaluate(); } catch (Throwable throwable) { logger.warning(Arrays.toString(throwable.getStackTrace())); } }
Example 5
Source File: TestsRegExFilterTest.java From android-test with Apache License 2.0 | 5 votes |
@Test public void partialClassName() { TestsRegExFilter filter = new TestsRegExFilter(); filter.setPattern("TestFixture"); Description d = Description.createTestDescription(TestFixture.class, "any"); assertThat(filter.evaluateTest(d)).isTrue(); }
Example 6
Source File: OrchestrationXmlTestRunListenerTest.java From android-test with Apache License 2.0 | 5 votes |
/** * A simple test to ensure expected output is generated for test run with a single passed test. */ @Test public void testSinglePass() { Description testDescription = Description.createTestDescription(CLASS_NAME, TEST_NAME, 1); resultReporter.orchestrationRunStarted(1); runTestSucceed(testDescription, true); resultReporter.orchestrationRunFinished(); String output = getOutput(); // TODO: consider doing xml based compare assertTrue(output.contains("tests=\"1\" failures=\"0\" errors=\"0\"")); final String testCaseTag = String.format("<testcase name=\"%s\" classname=\"%s\"", TEST_NAME, CLASS_NAME); assertTrue(output.contains(testCaseTag)); }
Example 7
Source File: TestSizeTest.java From android-test with Apache License 2.0 | 5 votes |
@Test public void classNotAnnotatedWithTestSize_ReturnsTrue() { Description testClassRunnerFilterSmallSizeTestDescription = Description.createTestDescription( SampleTestRunnerFilterSizeAnnotatedClass.class, "testMethod"); assertThat( testSize.testClassIsAnnotatedWithTestSize(testClassRunnerFilterSmallSizeTestDescription), equalTo(true)); Description testClassPlatformSmallSizeTestDescription = Description.createTestDescription(SampleTestPlatformSizeAnnotatedClass.class, "testMethod"); assertThat( testSize.testClassIsAnnotatedWithTestSize(testClassPlatformSmallSizeTestDescription), equalTo(true)); }
Example 8
Source File: SuiteAssignmentPrinterTest.java From android-test with Apache License 2.0 | 5 votes |
@Test public void timingInvalid_sendsFailure() throws Exception { Description description = Description.createTestDescription( SampleTestClassWithSizeAnnotations.class, "smallSizeTest"); doNothing().when(suiteAssignmentPrinter).sendStatus(anyInt(), any(Bundle.class)); suiteAssignmentPrinter.timingValid = false; suiteAssignmentPrinter.testFinished(description); verify(suiteAssignmentPrinter).sendString(eq("F")); }
Example 9
Source File: DirectoryRunner.java From EasyMPermission with MIT License | 5 votes |
private void addTests(Class<?> testClass) throws Exception { for (File file : params.getBeforeDirectory().listFiles(JAVA_FILE_FILTER)) { if (!params.accept(file)) continue; Description testDescription = Description.createTestDescription(testClass, file.getName()); description.addChild(testDescription); tests.put(file.getName(), testDescription); } }
Example 10
Source File: JUnit4RunnerTest.java From bazel with Apache License 2.0 | 5 votes |
@Test public void testPassingTest() throws Exception { config = createConfig(); mockRunListener = mock(RunListener.class); JUnit4Runner runner = createRunner(SamplePassingTest.class); Description testDescription = Description.createTestDescription(SamplePassingTest.class, "testThatAlwaysPasses"); Description suiteDescription = Description.createSuiteDescription(SamplePassingTest.class); suiteDescription.addChild(testDescription); Result result = runner.run(); assertThat(result.getRunCount()).isEqualTo(1); assertThat(result.getFailureCount()).isEqualTo(0); assertThat(result.getIgnoreCount()).isEqualTo(0); assertPassingTestHasExpectedOutput(stdoutByteStream, SamplePassingTest.class); InOrder inOrder = inOrder(mockRunListener); inOrder.verify(mockRunListener).testRunStarted(suiteDescription); inOrder.verify(mockRunListener).testStarted(testDescription); inOrder.verify(mockRunListener).testFinished(testDescription); inOrder.verify(mockRunListener).testRunFinished(any(Result.class)); }
Example 11
Source File: EndToEndRunner.java From buck with Apache License 2.0 | 5 votes |
/** * Needed for ParentRunner implementation, describeChild creates a testDescription from the * testMethod and the name we get from the test descriptor built off of environment configuration. */ @Override protected Description describeChild(EndToEndTestDescriptor child) { if (setupError != null) { return Description.createTestDescription(getTestClass().getJavaClass(), child.getName()); } return Description.createTestDescription( getTestClass().getJavaClass(), child.getName(), child.getMethod().getAnnotations()); }
Example 12
Source File: OrchestratedInstrumentationListenerTest.java From android-test with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); listener = new OrchestratedInstrumentationListener(this); listener.odoCallback = mockCallback; Class<SampleJUnitTest> testClass = SampleJUnitTest.class; jUnitDescription = Description.createTestDescription(testClass, "sampleTest"); jUnitFailure = new Failure(jUnitDescription, new Throwable("error")); jUnitResult = new Result(); RunListener jUnitListener = jUnitResult.createListener(); jUnitListener.testRunStarted(jUnitDescription); jUnitListener.testStarted(jUnitDescription); jUnitListener.testFinished(jUnitDescription); }
Example 13
Source File: SmartAssert.java From codenjoy with GNU General Public License v3.0 | 4 votes |
@Override public Description getDescription() { return Description.createTestDescription(test, "Do not panic! You have performed wonders in this... colourful Universe."); }
Example 14
Source File: ArchTestMethodExecution.java From ArchUnit with Apache License 2.0 | 4 votes |
@Override Description describeSelf() { return Description.createTestDescription(testClass, testMethod.getName()); }
Example 15
Source File: SingleTestRunner.java From joynr with Apache License 2.0 | 4 votes |
@Override protected Description describeChild(FrameworkMethod method) { return Description.createTestDescription(getTestClass().getJavaClass().getName(), testName(method), testName(method) + "-" + bounceProxySetup.getClass().getSimpleName()); }
Example 16
Source File: LoadTimeWeavableTestRunner.java From rice with Educational Community License v2.0 | 4 votes |
/** * Returns a {@link org.junit.runner.Description} for {@code child}, which can be assumed to * be an element of the list returned by {@link #getChildren()} */ protected Description describeChild(FrameworkMethod method) { return Description.createTestDescription(getTestClass().getJavaClass(), testName(method), method.getAnnotations()); }
Example 17
Source File: FlakyRuleTest.java From testcontainers-java with MIT License | 4 votes |
private Description newDescriptionWithAnnotationAndCustomTries(int maxTries) { return Description.createTestDescription("SomeTestClass", "someMethod", newAnnotation(VALID_DATE_IN_FAR_FUTURE, VALID_URL, maxTries)); }
Example 18
Source File: TestRunner.java From tutorials with MIT License | 4 votes |
@Override public Description getDescription() { return Description.createTestDescription(testClass, "My runner description"); }
Example 19
Source File: LoadTimeWeavableTestRunner.java From rice with Educational Community License v2.0 | 4 votes |
protected Description describeOriginalChild(FrameworkMethod method) { return Description.createTestDescription(getOriginalTestClass().getJavaClass(), testName(method), method.getAnnotations()); }
Example 20
Source File: SmartAssert.java From codenjoy with GNU General Public License v3.0 | 4 votes |
private Description description(Method method) { return Description.createTestDescription(test, method.getName()); }