mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 422962 - Boost Testrunner: BOOST_PARAM_TEST_CASE not working
Change-Id: I8815163c15ba9cd1c2fd0b5ba4ffe7a701fb6b3c Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/19679 Tested-by: Hudson CI
This commit is contained in:
parent
1b42998e47
commit
5428ad5001
3 changed files with 56 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2011 Anton Gorenkov
|
* Copyright (c) 2011, 2013 Anton Gorenkov and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Gorenkov - initial API and implementation
|
* Anton Gorenkov - initial API and implementation
|
||||||
|
* Marc-Andre Laperle (Ericsson)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.testsrunner.internal.boost;
|
package org.eclipse.cdt.testsrunner.internal.boost;
|
||||||
|
|
||||||
|
@ -87,7 +88,14 @@ public class BoostXmlLogHandler extends DefaultHandler {
|
||||||
/** Current test case status. */
|
/** Current test case status. */
|
||||||
private ITestItem.Status testStatus;
|
private ITestItem.Status testStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep track of the last test case name so that we can handle
|
||||||
|
* parameterized test cases which have the same name
|
||||||
|
*/
|
||||||
|
private String lastTestCaseName = ""; //$NON-NLS-1$
|
||||||
|
private static final int SAME_TEST_CASE_NAME_COUNT_START = 2;
|
||||||
|
private int sameTestCaseNameCount = SAME_TEST_CASE_NAME_COUNT_START;
|
||||||
|
|
||||||
BoostXmlLogHandler(ITestModelUpdater modelUpdater) {
|
BoostXmlLogHandler(ITestModelUpdater modelUpdater) {
|
||||||
this.modelUpdater = modelUpdater;
|
this.modelUpdater = modelUpdater;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +110,15 @@ public class BoostXmlLogHandler extends DefaultHandler {
|
||||||
|
|
||||||
} else if (qName == XML_NODE_TEST_CASE) {
|
} else if (qName == XML_NODE_TEST_CASE) {
|
||||||
String testCaseName = attrs.getValue(XML_ATTR_TEST_CASE_NAME);
|
String testCaseName = attrs.getValue(XML_ATTR_TEST_CASE_NAME);
|
||||||
|
|
||||||
|
if (lastTestCaseName.equals(testCaseName)) {
|
||||||
|
testCaseName += " (" + sameTestCaseNameCount + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
++sameTestCaseNameCount;
|
||||||
|
} else {
|
||||||
|
lastTestCaseName = testCaseName;
|
||||||
|
sameTestCaseNameCount = SAME_TEST_CASE_NAME_COUNT_START;
|
||||||
|
}
|
||||||
|
|
||||||
modelUpdater.enterTestCase(testCaseName);
|
modelUpdater.enterTestCase(testCaseName);
|
||||||
testStatus = Status.Passed;
|
testStatus = Status.Passed;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2011 Anton Gorenkov
|
* Copyright (c) 2011, 2013 Anton Gorenkov and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Gorenkov - initial implementation
|
* Anton Gorenkov - initial implementation
|
||||||
|
* Marc-Andre Laperle (Ericsson)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.testsrunner.testsrunners;
|
package org.eclipse.cdt.testsrunner.testsrunners;
|
||||||
|
|
||||||
|
@ -478,4 +479,33 @@ public class BoostTestCase extends BaseTestCase {
|
||||||
expectTestingException();
|
expectTestingException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <TestLog>
|
||||||
|
// <TestSuite name="MainTS">
|
||||||
|
// <TestCase name="test_function">
|
||||||
|
// </TestCase>
|
||||||
|
// <TestCase name="test_function">
|
||||||
|
// </TestCase>
|
||||||
|
// <TestCase name="test_function">
|
||||||
|
// </TestCase>
|
||||||
|
// <TestCase name="another_test_function">
|
||||||
|
// </TestCase>
|
||||||
|
// <TestCase name="another_test_function">
|
||||||
|
// </TestCase>
|
||||||
|
// </TestSuite>
|
||||||
|
// </TestLog>
|
||||||
|
public void testParameterizedTests() {
|
||||||
|
mockModelUpdater.skipCalls("setTestStatus");
|
||||||
|
mockModelUpdater.enterTestSuite("MainTS");
|
||||||
|
mockModelUpdater.enterTestCase("test_function");
|
||||||
|
mockModelUpdater.exitTestCase();
|
||||||
|
mockModelUpdater.enterTestCase("test_function (2)");
|
||||||
|
mockModelUpdater.exitTestCase();
|
||||||
|
mockModelUpdater.enterTestCase("test_function (3)");
|
||||||
|
mockModelUpdater.exitTestCase();
|
||||||
|
mockModelUpdater.enterTestCase("another_test_function");
|
||||||
|
mockModelUpdater.exitTestCase();
|
||||||
|
mockModelUpdater.enterTestCase("another_test_function (2)");
|
||||||
|
mockModelUpdater.exitTestCase();
|
||||||
|
mockModelUpdater.exitTestSuite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2011 Anton Gorenkov
|
* Copyright (c) 2011, 2013 Anton Gorenkov and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Gorenkov - initial API and implementation
|
* Anton Gorenkov - initial API and implementation
|
||||||
|
* Marc-Andre Laperle (Ericsson)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.testsrunner.internal.model;
|
package org.eclipse.cdt.testsrunner.internal.model;
|
||||||
|
|
||||||
|
@ -235,7 +236,9 @@ public class TestModelManager implements ITestModelUpdater, ITestModelAccessor {
|
||||||
for (int childIndex = 0; childIndex < lastInsertIndex; childIndex++) {
|
for (int childIndex = 0; childIndex < lastInsertIndex; childIndex++) {
|
||||||
newTestItem = checkTestItem(children.get(childIndex), name);
|
newTestItem = checkTestItem(children.get(childIndex), name);
|
||||||
if (newTestItem != null) {
|
if (newTestItem != null) {
|
||||||
children.add(lastInsertIndex, children.remove(childIndex));
|
TestItem removed = children.remove(childIndex);
|
||||||
|
lastInsertIndex = Math.min(lastInsertIndex, children.size());
|
||||||
|
children.add(lastInsertIndex, removed);
|
||||||
notifyAboutChildrenUpdate(currTestSuite);
|
notifyAboutChildrenUpdate(currTestSuite);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue