forked from twitter/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture testcase for unknown test failures in the JUnit Xml
Testing Done: Travis CI: https://travis-ci.org/pantsbuild/pants/builds/176145705 When the Mockito test runner comes across a mock that is unneeded it calls the test listener with a test failure for an unknown test case name. We want to capture these failures as testcases in the xml output. e.g. ``` Following stubbings are unnecessary (click to navigate to relevant line of code): 1. -> at com.example.SampleTest.setUp(SampleTest.java:63) Please remove unnecessary stubbings or use 'silent' option. More info: javadoc for UnnecessaryStubbingException class. at org.mockito.internal.exceptions.Reporter.formatUnncessaryStubbingException(Reporter.java:838) at org.mockito.internal.junit.UnnecessaryStubbingsReporter.validateUnusedStubs(UnnecessaryStubbingsReporter.java:34) at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:49) at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:104) ``` Bugs closed: 4054 Reviewed at https://rbcommons.com/s/twitter/r/4377/
- Loading branch information
Showing
5 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
jar_library( | ||
name='mockito-core', | ||
jars=[ | ||
jar(org='org.mockito', name='mockito-core', rev='2.2.16'), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/java/org/pantsbuild/tools/junit/lib/XmlReportMockitoStubbingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
package org.pantsbuild.tools.junit.lib; | ||
|
||
import javax.net.ssl.SSLSession; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* This test is intentionally under a java_library() BUILD target so it will not be run | ||
* on its own. It is run by the ConsoleRunnerTest suite to test ConsoleRunnerImpl. | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class XmlReportMockitoStubbingTest { | ||
@Mock SSLSession sslSession; | ||
|
||
@Test | ||
public void testUnnecesaryMockingError() { | ||
when(sslSession.getCipherSuite()).thenReturn("cipher"); | ||
Assert.assertTrue(true); | ||
} | ||
} |