diff --git a/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParser.java b/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParser.java index b7cf90dbfd35..0fea385ea007 100644 --- a/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParser.java +++ b/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParser.java @@ -38,7 +38,7 @@ */ public final class PhpUnitLogParser extends DefaultHandler { - enum Content { NONE, ERROR, FAILURE }; + enum Content { NONE, ERROR, FAILURE, SKIPPED }; private static final Logger LOGGER = Logger.getLogger(PhpUnitLogParser.class.getName()); private static final String NO_FILE = "NO_FILE"; // NOI18N @@ -90,6 +90,8 @@ public void startElement(String uri, String localName, String qName, Attributes startTestFailure(attributes); } else if ("error".equals(qName)) { // NOI18N startTestError(attributes); + } else if ("skipped".equals(qName)) { // NOI18N + startTestSkipped(attributes); } } @@ -111,6 +113,7 @@ public void characters(char[] ch, int start, int length) throws SAXException { switch (content) { case FAILURE: case ERROR: + case SKIPPED: buffer.append(new String(ch, start, length)); break; case NONE: @@ -169,6 +172,11 @@ private void startTestFailure(Attributes attributes) { content = Content.FAILURE; } + private void startTestSkipped(Attributes attributes) { + content = Content.SKIPPED; + testCase.setSkippedStatus(); + } + private void endTestContent() { assert testCase != null; assert buffer.length() > 0; diff --git a/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/TestCaseVo.java b/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/TestCaseVo.java index 7b415222cf8c..6836cc55b389 100644 --- a/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/TestCaseVo.java +++ b/php/php.phpunit/src/org/netbeans/modules/php/phpunit/run/TestCaseVo.java @@ -155,6 +155,11 @@ public void setFailureStatus() { status = TestCase.Status.FAILED; } + public void setSkippedStatus() { + assert status == TestCase.Status.PASSED : "Expected PASSED status but was: " + status; // NOI18N + status = TestCase.Status.SKIPPED; + } + public TestCase.Status getStatus() { return status; } @@ -167,6 +172,10 @@ public boolean isFailure() { return status.equals(TestCase.Status.FAILED); } + public boolean isSkipped() { + return status.equals(TestCase.Status.SKIPPED); + } + @Override public String toString() { return String.format("TestCaseVo{name: %s, file: %s, line: %d, time: %d, status: %s, stacktrace: %s}", name, file, line, time, status, stacktrace); // NOI18N diff --git a/php/php.phpunit/test/unit/data/phpunit-log-skipped-tests.xml b/php/php.phpunit/test/unit/data/phpunit-log-skipped-tests.xml new file mode 100644 index 000000000000..6a04d794bc6f --- /dev/null +++ b/php/php.phpunit/test/unit/data/phpunit-log-skipped-tests.xml @@ -0,0 +1,40 @@ + + + + + + + CalculatorTest::testPlus2 +Failed asserting that 1 matches expected 2. + +/home/troizet/NetBeansProjects/Calculator-PHPUnit/test/src/CalculatorTest.php:55 + + + + + + + + + + + + + + CalculatorTest::testDivide +Failed asserting that 0 matches expected 2. + +/home/troizet/NetBeansProjects/Calculator-PHPUnit/test/src/CalculatorTest.php:142 + + + + + + + + + + + + + diff --git a/php/php.phpunit/test/unit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParserTest.java b/php/php.phpunit/test/unit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParserTest.java index 9c467ea9add0..90423e0eeb5a 100644 --- a/php/php.phpunit/test/unit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParserTest.java +++ b/php/php.phpunit/test/unit/src/org/netbeans/modules/php/phpunit/run/PhpUnitLogParserTest.java @@ -24,6 +24,7 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.Reader; +import java.util.Arrays; import org.netbeans.junit.NbTestCase; import org.netbeans.modules.php.spi.testing.run.TestCase; @@ -295,6 +296,22 @@ public void testParseLogNETBEANS1851() throws Exception { assertEquals("Risky Test", testCase.getStackTrace()[0]); } + public void testParseLogSkippedTests() throws Exception { + Reader reader = createReader("phpunit-log-skipped-tests.xml"); + TestSessionVo testSession = new TestSessionVo(null); + + PhpUnitLogParser.parse(reader, testSession); + + assertSame(1, testSession.getTestSuites().size()); + TestSuiteVo testSuite = testSession.getTestSuites().get(0); + assertEquals("CalculatorTest", testSuite.getName()); + assertEquals("/home/troizet/NetBeansProjects/Calculator-PHPUnit/test/src/CalculatorTest.php", testSuite.getFile()); + TestCaseVo testCase = testSuite.getTestCases().get(15); + assertEquals("testDivide3", testCase.getName()); + assertTrue(testCase.isSkipped()); + assertTrue(Arrays.asList(testCase.getStackTrace()).isEmpty()); + } + private Reader createReader(String filename) throws FileNotFoundException { return new BufferedReader(new FileReader(new File(getDataDir(), filename))); }