Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Gorenkov2012-04-17 23:50:07 -0400
committerMarc-Andre Laperle2012-04-17 23:50:07 -0400
commitf16f0dbe483fd8fe1b2c5ab343d03201bfcccbf9 (patch)
treef4c19f2733b05d642eeb14ec90a79065640ae23e /testsrunner/org.eclipse.cdt.testsrunner.test
parent83cf5dc8303da5df560bde6ebb602b1e5cc59fb8 (diff)
downloadorg.eclipse.cdt-f16f0dbe483fd8fe1b2c5ab343d03201bfcccbf9.tar.gz
org.eclipse.cdt-f16f0dbe483fd8fe1b2c5ab343d03201bfcccbf9.tar.xz
org.eclipse.cdt-f16f0dbe483fd8fe1b2c5ab343d03201bfcccbf9.zip
Bug 210366 - CDT should have Unit Testing and Component Testing like JDT
Diffstat (limited to 'testsrunner/org.eclipse.cdt.testsrunner.test')
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/.classpath7
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/.project28
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/.settings/org.eclipse.jdt.core.prefs82
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/META-INF/MANIFEST.MF16
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/OSGI-INF/l10n/bundle.properties13
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/about.html24
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/build.properties20
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/pom.xml42
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerBaseReorderingTestCase.java123
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerCasesReorderingTestCase.java40
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerSuitesReorderingTestCase.java39
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerSuite.java55
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerTestActivator.java48
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BaseTestCase.java99
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java481
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/GoogleTestCase.java698
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/MockTestModelUpdater.java221
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/QtTestCase.java693
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.test/test.xml56
19 files changed, 2785 insertions, 0 deletions
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/.classpath b/testsrunner/org.eclipse.cdt.testsrunner.test/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/.project b/testsrunner/org.eclipse.cdt.testsrunner.test/.project
new file mode 100644
index 0000000000..fcfb09a776
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.testsrunner.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/.settings/org.eclipse.jdt.core.prefs b/testsrunner/org.eclipse.cdt.testsrunner.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..0e860bfc27
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,82 @@
+#Mon Apr 16 13:01:24 EEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/META-INF/MANIFEST.MF b/testsrunner/org.eclipse.cdt.testsrunner.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..8753f5de41
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.cdt.testsrunner.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.testsrunner.test.TestsRunnerTestActivator
+Require-Bundle: org.junit,
+ org.eclipse.core.runtime,
+ org.eclipse.cdt.core.tests,
+ org.eclipse.cdt.testsrunner;bundle-version="7.0.0",
+ org.eclipse.cdt.testsrunner.boost;bundle-version="7.0.0",
+ org.eclipse.cdt.testsrunner.qttest;bundle-version="7.0.0",
+ org.eclipse.cdt.testsrunner.gtest;bundle-version="7.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: %Bundle-Vendor
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/OSGI-INF/l10n/bundle.properties b/testsrunner/org.eclipse.cdt.testsrunner.test/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000000..c93c6763da
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2011 Anton Gorenkov
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Anton Gorenkov - Initial implementation
+###############################################################################
+#Properties file for org.eclipse.cdt.testsrunner.test
+Bundle-Name = C/C++ Development Tools Tests Running Support Tests
+Bundle-Vendor = Eclipse CDT \ No newline at end of file
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/about.html b/testsrunner/org.eclipse.cdt.testsrunner.test/about.html
new file mode 100644
index 0000000000..d7c511887d
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 22, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/build.properties b/testsrunner/org.eclipse.cdt.testsrunner.test/build.properties
new file mode 100644
index 0000000000..6717294699
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/build.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2011 Anton Gorenkov
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Anton Gorenkov - Initial implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ src/,\
+ OSGI-INF/,\
+ test.xml,\
+ about.html
+jre.compilation.profile = J2SE-1.5
+src.includes = about.html
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/pom.xml b/testsrunner/org.eclipse.cdt.testsrunner.test/pom.xml
new file mode 100644
index 0000000000..0606be0432
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>8.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>org.eclipse.cdt.testsrunner.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <repositories>
+ <repository>
+ <id>cdt.repo</id>
+ <url>file:/${basedir}/../../releng/org.eclipse.cdt.repo/target/repository</url>
+ <layout>p2</layout>
+ </repository>
+</repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <useUIHarness>true</useUIHarness>
+ <includes>
+ <include>**/TestsRunnerSuite.*</include>
+ </includes>
+ <testFailureIgnore>true</testFailureIgnore>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerBaseReorderingTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerBaseReorderingTestCase.java
new file mode 100644
index 0000000000..5d9713be59
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerBaseReorderingTestCase.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.testsrunner.internal.model.TestModelManager;
+import org.eclipse.cdt.testsrunner.model.ITestItem;
+import org.eclipse.cdt.testsrunner.model.ITestSuite;
+
+
+/**
+ * Base test case for test suites & test cases reordering in TestModelManager.
+ */
+@SuppressWarnings("nls")
+public abstract class TestModelManagerBaseReorderingTestCase extends TestCase {
+
+ protected TestModelManager modelManager;
+ protected List<String> expectedSuitesOrder = new ArrayList<String>();
+
+
+ protected abstract ITestSuite createTestsHierarchy();
+
+ protected abstract void visitTestItem(String name);
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ modelManager = new TestModelManager(createTestsHierarchy(), false);
+ modelManager.testingStarted();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ modelManager.testingFinished();
+ ITestItem[] rootTestSuiteChildren = modelManager.getRootSuite().getChildren();
+ assertEquals("Unexpected children count", expectedSuitesOrder.size(), rootTestSuiteChildren.length);
+ for (int i = 0; i < rootTestSuiteChildren.length; i++) {
+ assertEquals("Unexpected child name", expectedSuitesOrder.get(i), rootTestSuiteChildren[i].getName());
+ }
+ }
+
+ private void visitTestItemWithExpectation(String name) {
+ visitTestItem(name);
+ expectedSuitesOrder.add(name);
+ }
+
+ public void testNoReordering() {
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("item2");
+ visitTestItemWithExpectation("item3");
+ }
+
+ public void testItemAdd() {
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("itemNew");
+ visitTestItemWithExpectation("item2");
+ visitTestItemWithExpectation("item3");
+ }
+
+ public void testItemAddToBeginAndEnd() {
+ visitTestItemWithExpectation("itemNew");
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("item2");
+ visitTestItemWithExpectation("item3");
+ visitTestItemWithExpectation("itemNew2");
+ }
+
+ public void testItemRemove() {
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("item3");
+ }
+
+ public void testItemRemoveFromBeginAndEnd() {
+ visitTestItemWithExpectation("item2");
+ }
+
+ public void testItemRemoveAndAdd() {
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("itemNew");
+ visitTestItemWithExpectation("item3");
+ }
+
+ public void testItemOrderChange() {
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("item3");
+ visitTestItemWithExpectation("item2");
+ }
+
+ public void testItemReverse() {
+ visitTestItemWithExpectation("item3");
+ visitTestItemWithExpectation("item2");
+ visitTestItemWithExpectation("item1");
+ }
+
+ public void testItemVisitTwice() {
+ visitTestItem("item1");
+ visitTestItemWithExpectation("item2");
+ visitTestItemWithExpectation("item1");
+ visitTestItem("item3");
+ visitTestItemWithExpectation("item3");
+ }
+
+ public void testItemVisitTwiceAndReorder() {
+ visitTestItem("item3");
+ visitTestItemWithExpectation("item1");
+ visitTestItemWithExpectation("item3");
+ visitTestItemWithExpectation("item2");
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerCasesReorderingTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerCasesReorderingTestCase.java
new file mode 100644
index 0000000000..31c382eaa2
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerCasesReorderingTestCase.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.core;
+
+import org.eclipse.cdt.testsrunner.internal.model.TestCase;
+import org.eclipse.cdt.testsrunner.internal.model.TestModelManager;
+import org.eclipse.cdt.testsrunner.internal.model.TestSuite;
+import org.eclipse.cdt.testsrunner.model.ITestSuite;
+
+
+/**
+ * Tests on the test cases reordering in TestModelManager.
+ */
+@SuppressWarnings("nls")
+public class TestModelManagerCasesReorderingTestCase extends TestModelManagerBaseReorderingTestCase {
+
+ @Override
+ protected ITestSuite createTestsHierarchy() {
+ TestSuite rootTestSuite = new TestSuite(TestModelManager.ROOT_TEST_SUITE_NAME, null);
+ rootTestSuite.getChildrenList().add(new TestCase("item1", rootTestSuite));
+ rootTestSuite.getChildrenList().add(new TestCase("item2", rootTestSuite));
+ rootTestSuite.getChildrenList().add(new TestCase("item3", rootTestSuite));
+ return rootTestSuite;
+ }
+
+ @Override
+ protected void visitTestItem(String name) {
+ modelManager.enterTestCase(name);
+ modelManager.exitTestCase();
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerSuitesReorderingTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerSuitesReorderingTestCase.java
new file mode 100644
index 0000000000..3a1332e342
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/core/TestModelManagerSuitesReorderingTestCase.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.core;
+
+import org.eclipse.cdt.testsrunner.internal.model.TestModelManager;
+import org.eclipse.cdt.testsrunner.internal.model.TestSuite;
+import org.eclipse.cdt.testsrunner.model.ITestSuite;
+
+
+/**
+ * Tests on the test suites reordering in TestModelManager.
+ */
+@SuppressWarnings("nls")
+public class TestModelManagerSuitesReorderingTestCase extends TestModelManagerBaseReorderingTestCase {
+
+ @Override
+ protected ITestSuite createTestsHierarchy() {
+ TestSuite rootTestSuite = new TestSuite(TestModelManager.ROOT_TEST_SUITE_NAME, null);
+ rootTestSuite.getChildrenList().add(new TestSuite("item1", rootTestSuite));
+ rootTestSuite.getChildrenList().add(new TestSuite("item2", rootTestSuite));
+ rootTestSuite.getChildrenList().add(new TestSuite("item3", rootTestSuite));
+ return rootTestSuite;
+ }
+
+ @Override
+ protected void visitTestItem(String name) {
+ modelManager.enterTestSuite(name);
+ modelManager.exitTestSuite();
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerSuite.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerSuite.java
new file mode 100644
index 0000000000..1d4b249931
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerSuite.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.testsrunner.core.TestModelManagerCasesReorderingTestCase;
+import org.eclipse.cdt.testsrunner.core.TestModelManagerSuitesReorderingTestCase;
+import org.eclipse.cdt.testsrunner.testsrunners.BoostTestCase;
+import org.eclipse.cdt.testsrunner.testsrunners.GoogleTestCase;
+import org.eclipse.cdt.testsrunner.testsrunners.QtTestCase;
+
+
+/**
+ * Test suite with all the tests on Tests Runner.
+ */
+public class TestsRunnerSuite extends TestSuite {
+
+ public TestsRunnerSuite() {
+ }
+
+ public TestsRunnerSuite(Class<? extends TestCase> theClass, String name) {
+ super(theClass, name);
+ }
+
+ public TestsRunnerSuite(Class<? extends TestCase> theClass) {
+ super(theClass);
+ }
+
+ public TestsRunnerSuite(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ final TestsRunnerSuite suite = new TestsRunnerSuite();
+ // Core
+ suite.addTestSuite(TestModelManagerSuitesReorderingTestCase.class);
+ suite.addTestSuite(TestModelManagerCasesReorderingTestCase.class);
+ // Tests Runners Plug-ins
+ suite.addTestSuite(BoostTestCase.class);
+ suite.addTestSuite(GoogleTestCase.class);
+ suite.addTestSuite(QtTestCase.class);
+ return suite;
+ }
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerTestActivator.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerTestActivator.java
new file mode 100644
index 0000000000..375b7500b4
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/test/TestsRunnerTestActivator.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.test;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class TestsRunnerTestActivator extends Plugin {
+
+ /** The plug-in ID .*/
+ public static final String PLUGIN_ID = "org.eclipse.cdt.testsrunner.test"; //$NON-NLS-1$
+
+ /** Plug-in instance. */
+ private static TestsRunnerTestActivator plugin;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared plug-in instance.
+ *
+ * @return the plug-in instance
+ */
+ public static TestsRunnerTestActivator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BaseTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BaseTestCase.java
new file mode 100644
index 0000000000..1d6be7e13c
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BaseTestCase.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.testsrunners;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
+import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.model.TestingException;
+import org.eclipse.cdt.testsrunner.test.TestsRunnerTestActivator;
+import org.eclipse.core.runtime.Plugin;
+
+
+/**
+ * Base test case for Tests Runner provider plug-ins testing.
+ */
+@SuppressWarnings("nls")
+public abstract class BaseTestCase extends TestCase {
+
+ protected static final String EOL = System.getProperty("line.separator");
+
+ protected MockTestModelUpdater mockModelUpdater = new MockTestModelUpdater();
+ protected ITestsRunnerProvider testsRunner = createTestsRunner();
+ protected boolean expectTestingException = false;
+
+
+ protected abstract ITestsRunnerProvider createTestsRunner();
+
+ protected String getAboveComment() {
+ return getContents(1)[0].toString();
+ }
+
+ private StringBuilder[] getContents(int sections) {
+ try {
+ return TestSourceReader.getContentsForTest(getPlugin().getBundle(), getSourcePrefix(), getClass(), getName(), sections);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ return null;
+ }
+ }
+
+ protected Plugin getPlugin() {
+ return TestsRunnerTestActivator.getDefault();
+ }
+
+ protected String getSourcePrefix() {
+ return "src";
+ }
+
+ protected void runTestsRunner() throws TestingException {
+ try {
+ mockModelUpdater.replay();
+ String inputString = getAboveComment();
+ InputStream inStream = new ByteArrayInputStream(inputString.getBytes("UTF-8"));
+ boolean testingExceptionHappen = false;
+ String exceptionMessage = null;
+ try {
+ testsRunner.run(mockModelUpdater, inStream);
+
+ } catch (TestingException e) {
+ testingExceptionHappen = true;
+ exceptionMessage = e.getMessage();
+ }
+ if (expectTestingException != testingExceptionHappen) {
+ if (testingExceptionHappen) {
+ fail("Unexpected exception: "+exceptionMessage);
+ } else {
+ fail("TestingException is expected, but did not happen!");
+ }
+ }
+
+ } catch (UnsupportedEncodingException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ protected void expectTestingException() {
+ expectTestingException = true;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ runTestsRunner();
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java
new file mode 100644
index 0000000000..053a5ea553
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java
@@ -0,0 +1,481 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.testsrunners;
+
+import org.eclipse.cdt.testsrunner.internal.boost.BoostTestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.model.ITestItem;
+import org.eclipse.cdt.testsrunner.model.ITestMessage;
+
+
+/**
+ * Tests for {@see BoostTestsRunner} class
+ */
+@SuppressWarnings("nls")
+public class BoostTestCase extends BaseTestCase {
+
+ private static final String DEFAULT_LOCATION_FILE = null;
+ private static final int DEFAULT_LOCATION_LINE = -1;
+ private static final String EXCEPTION_CHECKPOINT_SUFFIX = "\nLast check point was here.";
+
+ @Override
+ public ITestsRunnerProvider createTestsRunner() {
+ return new BoostTestsRunnerProvider();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test"/>
+ // </TestSuite>
+ //</TestLog>
+ public void testTheOnlyTestCase() {
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test1"/>
+ // <TestCase name="test2"/>
+ // <TestCase name="test3"/>
+ // </TestSuite>
+ //</TestLog>
+ public void testAFewTestCases() {
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test1");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test3");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestSuite name="InnerTS"/>
+ // </TestSuite>
+ //</TestLog>
+ public void testEmptyTestSuite() {
+ // NOTE: This is impossible input data (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestSuite("InnerTS");
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestSuite name="InnerTS">
+ // <TestCase name="test1"/>
+ // <TestCase name="test2"/>
+ // <TestCase name="test3"/>
+ // </TestSuite>
+ // </TestSuite>
+ //</TestLog>
+ public void testAFewTestCasesInTestSuite() {
+ // NOTE: This is impossible input data (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestSuite("InnerTS");
+ mockModelUpdater.enterTestCase("test1");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test3");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestSuite name="InnerTS">
+ // <TestSuite name="InnerInnerTS"/>
+ // </TestSuite>
+ // </TestSuite>
+ //</TestLog>
+ public void testEmptyTestSuiteInTestSuite() {
+ // NOTE: This is impossible input data (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestSuite("InnerTS");
+ mockModelUpdater.enterTestSuite("InnerInnerTS");
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestSuite name="InnerTS">
+ // <TestSuite name="InnerInnerTS">
+ // <TestCase name="test1"/>
+ // </TestSuite>
+ // <TestCase name="test2"/>
+ // <TestCase name="test3"/>
+ // </TestSuite>
+ // </TestSuite>
+ // <TestCase name="test4">
+ // </TestCase>
+ //</TestLog>
+ public void testSimpleTestsHierarchy() {
+ // NOTE: This is impossible input data (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestSuite("InnerTS");
+ mockModelUpdater.enterTestSuite("InnerInnerTS");
+ mockModelUpdater.enterTestCase("test1");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.enterTestCase("test2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test3");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.enterTestCase("test4");
+ mockModelUpdater.exitTestCase();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="testPass">
+ // <Info file="file.cpp" line="22">check 1 passed</Info>
+ // </TestCase>
+ // <TestCase name="testPassWithWarning">
+ // <Warning file="file.cpp" line="27">condition 0 is not satisfied</Warning>
+ // <Message file="file2.h" line="220">Test case testPassWithWarning did not run any assertions</Message>
+ // </TestCase>
+ // <TestCase name="testPassIfEmpty">
+ // <Message file="file2.h" line="220">Test case testPassIfEmpty did not run any assertions</Message>
+ // </TestCase>
+ // <TestCase name="testFailWithCheck">
+ // <Error file="file.cpp" line="32">check 0 failed</Error>
+ // <Info file="file.cpp" line="33">check 1 passed</Info>
+ // </TestCase>
+ // <TestCase name="testFailWithRequire">
+ // <FatalError file="file.cpp" line="38">critical check 0 failed</FatalError>
+ // </TestCase>
+ // <TestCase name="testAbortedOnException">
+ // <Exception>unknown type</Exception>
+ // </TestCase>
+ // <TestCase name="testAbortedOnNullDereference">
+ // <Exception>memory access violation at address: 0x00000000: no mapping at fault address</Exception>
+ // <Message file="file2.h" line="164">Test is aborted</Message>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testDifferentTestStatuses() {
+ mockModelUpdater.skipCalls("addTestMessage");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("testPass");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testPassWithWarning");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testPassIfEmpty");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testFailWithCheck");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testFailWithRequire");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testAbortedOnException");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Aborted);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testAbortedOnNullDereference");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Aborted);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test">
+ // <Info file="file.cpp" line="22"/>
+ // <Exception><LastCheckpoint file="file2.cpp" line="47"/></Exception>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testEmptyMessage() {
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test");
+ mockModelUpdater.addTestMessage("file.cpp", 22, ITestMessage.Level.Info, "");
+ mockModelUpdater.addTestMessage("file2.cpp", 47, ITestMessage.Level.Exception, EXCEPTION_CHECKPOINT_SUFFIX);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test">
+ // <Warning file="file" line="42"> Custom warning </Warning>
+ // <Exception> Exception message <LastCheckpoint file="file2" line="47"/> end </Exception>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testSpacesInBeginAndEndOfMessage() {
+ // NOTE: Last checkpoint tag cannot be in the middle of exception (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test");
+ mockModelUpdater.addTestMessage("file", 42, ITestMessage.Level.Warning, " Custom warning ");
+ mockModelUpdater.addTestMessage("file2", 47, ITestMessage.Level.Exception, " Exception message end "+EXCEPTION_CHECKPOINT_SUFFIX);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test">
+ // <Warning>Custom warning</Warning>
+ // <Exception file="file.cpp" line="1">Exceptions should be located by pass point</Exception>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testMessageWithoutLocation() {
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Warning, "Custom warning");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Exception, "Exceptions should be located by pass point");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test">
+ // <Warning file="file.cpp">No line number</Warning>
+ // <Warning file="" line="1">Empty file name</Warning>
+ // <Warning line="2">No file name</Warning>
+ // <Exception>Exception without line number<LastCheckpoint file="file2.cpp"/></Exception>
+ // <Exception>Exception with empty file name<LastCheckpoint file="" line="3"/></Exception>
+ // <Exception>Exception without file name<LastCheckpoint line="4"/></Exception>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testMessageWithLocation() {
+ // NOTE: This is impossible input data (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test");
+ mockModelUpdater.addTestMessage("file.cpp", DEFAULT_LOCATION_LINE, ITestMessage.Level.Warning, "No line number");
+ mockModelUpdater.addTestMessage("", 1, ITestMessage.Level.Warning, "Empty file name");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, 2, ITestMessage.Level.Warning, "No file name");
+ // NOTE: Last check point is not available, so EXCEPTION_CHECKPOINT_SUFFIX should not be added
+ mockModelUpdater.addTestMessage("file2.cpp", DEFAULT_LOCATION_LINE, ITestMessage.Level.Exception, "Exception without line number");
+ mockModelUpdater.addTestMessage("", 3, ITestMessage.Level.Exception, "Exception with empty file name");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, 4, ITestMessage.Level.Exception, "Exception without file name");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="test1">
+ // <Error file="file1.cpp" line="1">Message with location</Error>
+ // <Error>Message without location</Error>
+ // </TestCase>
+ // <TestCase name="test2">
+ // <Exception>Exception with location<LastCheckpoint file="file2.cpp" line="2"/></Exception>
+ // <Exception>Exception without location<LastCheckpoint/></Exception>
+ // </TestCase>
+ // <TestCase name="test3">
+ // <Error file="file3.cpp" line="3">Another message with location</Error>
+ // <Exception>Another exception without location</Exception>
+ // </TestCase>
+ // <TestCase name="test4">
+ // <Exception>Another exception with location<LastCheckpoint file="file4.cpp" line="4"/></Exception>
+ // <Error>Another message without location</Error>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testMessagesWithAndWithoutLocation() {
+ // NOTE: This is impossible input data (at least, for current version of Boost), but we check it anyway
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("test1");
+ mockModelUpdater.addTestMessage("file1.cpp", 1, ITestMessage.Level.Error, "Message with location");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Error, "Message without location");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test2");
+ mockModelUpdater.addTestMessage("file2.cpp", 2, ITestMessage.Level.Exception, "Exception with location"+EXCEPTION_CHECKPOINT_SUFFIX);
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Exception, "Exception without location");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test3");
+ mockModelUpdater.addTestMessage("file3.cpp", 3, ITestMessage.Level.Error, "Another message with location");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Exception, "Another exception without location");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("test4");
+ mockModelUpdater.addTestMessage("file4.cpp", 4, ITestMessage.Level.Exception, "Another exception with location"+EXCEPTION_CHECKPOINT_SUFFIX);
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Error, "Another message without location");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="testPass">
+ // <Info file="file.cpp" line="22">check 1 passed</Info>
+ // <TestingTime>1000</TestingTime>
+ // </TestCase>
+ // <TestCase name="testFail">
+ // <FatalError file="file2.cpp" line="38">critical check 0 failed</FatalError>
+ // <TestingTime>2000</TestingTime>
+ // </TestCase>
+ // <TestCase name="testAbortedOnException">
+ // <Exception>exception message</Exception>
+ // <TestingTime>3000</TestingTime>
+ // </TestCase>
+ // <TestCase name="testAbortedOnNullDereference">
+ // <Exception>another exception message</Exception>
+ // <Message file="file3.h" line="164">Test is aborted</Message>
+ // <TestingTime>4000</TestingTime>
+ // </TestCase>
+ // <TestCase name="testAbortedOnExceptionWithLocation">
+ // <Exception>yet another exception message<LastCheckpoint file="file4.cpp" line="47"/></Exception>
+ // <TestingTime>5000</TestingTime>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testExecutionTimePresence() {
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("testPass");
+ mockModelUpdater.addTestMessage("file.cpp", 22, ITestMessage.Level.Info, "check 1 passed");
+ mockModelUpdater.setTestingTime(1);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testFail");
+ mockModelUpdater.addTestMessage("file2.cpp", 38, ITestMessage.Level.FatalError, "critical check 0 failed");
+ mockModelUpdater.setTestingTime(2);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testAbortedOnException");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Exception, "exception message");
+ mockModelUpdater.setTestingTime(3);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testAbortedOnNullDereference");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Exception, "another exception message");
+ mockModelUpdater.addTestMessage("file3.h", 164, ITestMessage.Level.Message, "Test is aborted");
+ mockModelUpdater.setTestingTime(4);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testAbortedOnExceptionWithLocation");
+ mockModelUpdater.addTestMessage("file4.cpp", 47, ITestMessage.Level.Exception, "yet another exception message"+EXCEPTION_CHECKPOINT_SUFFIX);
+ mockModelUpdater.setTestingTime(5);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //
+ public void testNoInput() {
+ // NOTE: The comment above is left blank intentionally
+ expectTestingException();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="testPass">
+ // <!-- TestCase is not closed -->
+ // </TestSuite>
+ //</TestLog>
+ public void testBadFormedXml() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="testPass">
+ public void testUnexceptedXmlEnd() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <UnexpectedXmlElement name="testPass">
+ // <Info file="file.cpp" line="22">check 1 passed</Info>
+ // <TestingTime>100</TestingTime>
+ // </UnexpectedXmlElement>
+ // </TestSuite>
+ //</TestLog>
+ public void testUnexpectedXmlElement() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ expectTestingException();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="testPass">
+ // <Info file="file.cpp" line="wrong_value">check 1 passed</Info>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testWrongLineNumberValue() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+
+ //<TestLog>
+ // <TestSuite name="MainTS">
+ // <TestCase name="testPass">
+ // <TestingTime>wrong value</TestingTime>
+ // </TestCase>
+ // </TestSuite>
+ //</TestLog>
+ public void testWrongExecutionTimeValue() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/GoogleTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/GoogleTestCase.java
new file mode 100644
index 0000000000..ef561b6ae7
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/GoogleTestCase.java
@@ -0,0 +1,698 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.testsrunners;
+
+import org.eclipse.cdt.testsrunner.internal.gtest.GoogleTestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.model.ITestItem;
+import org.eclipse.cdt.testsrunner.model.ITestMessage;
+
+
+/**
+ * Tests for {@see GoogleTestsRunner} class
+ */
+@SuppressWarnings("nls")
+public class GoogleTestCase extends BaseTestCase {
+
+ private static final String DEFAULT_LOCATION_FILE = null;
+ private static final int DEFAULT_LOCATION_LINE = 1;
+
+ @Override
+ protected ITestsRunnerProvider createTestsRunner() {
+ return new GoogleTestsRunnerProvider();
+ }
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 0 tests from 0 test cases.
+ //[==========] 0 tests from 0 test cases ran. (0 ms total)
+ //[ PASSED ] 0 tests.
+ public void testNoTestCases() {
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest
+ //[ OK ] DemoTestCase.DemoTest (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ public void testTheOnlyTestCase() {
+ mockModelUpdater.skipCalls("setTestStatus");
+ mockModelUpdater.skipCalls("setTestingTime");
+
+ mockModelUpdater.enterTestSuite("DemoTestCase");
+ mockModelUpdater.enterTestCase("DemoTest");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 3 tests from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 3 tests from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest1
+ //[ OK ] DemoTestCase.DemoTest1 (0 ms)
+ //[ RUN ] DemoTestCase.DemoTest2
+ //[ OK ] DemoTestCase.DemoTest2 (0 ms)
+ //[ RUN ] DemoTestCase.DemoTest3
+ //[ OK ] DemoTestCase.DemoTest3 (0 ms)
+ //[----------] 3 tests from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 3 tests from 1 test case ran. (0 ms total)
+ //[ PASSED ] 3 tests.
+ public void testAFewTestCasesInTheOnlyTestSuites() {
+ mockModelUpdater.skipCalls("setTestStatus");
+ mockModelUpdater.skipCalls("setTestingTime");
+
+ mockModelUpdater.enterTestSuite("DemoTestCase");
+ mockModelUpdater.enterTestCase("DemoTest1");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("DemoTest2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("DemoTest3");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 2 tests from 2 test cases.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest
+ //[ OK ] DemoTestCase.DemoTest (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //
+ //[----------] 1 test from DemoTestCase2
+ //[ RUN ] DemoTestCase2.DemoTest2
+ //[ OK ] DemoTestCase2.DemoTest2 (0 ms)
+ //[----------] 1 test from DemoTestCase2 (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 2 tests from 2 test cases ran. (0 ms total)
+ //[ PASSED ] 2 tests.
+ public void testTheOnlyTestCasesInAFewTestSuites() {
+ mockModelUpdater.skipCalls("setTestStatus");
+ mockModelUpdater.skipCalls("setTestingTime");
+
+ mockModelUpdater.enterTestSuite("DemoTestCase");
+ mockModelUpdater.enterTestCase("DemoTest");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.enterTestSuite("DemoTestCase2");
+ mockModelUpdater.enterTestCase("DemoTest2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 4 tests from 2 test cases.
+ //[----------] Global test environment set-up.
+ //[----------] 2 tests from DemoTestCase1
+ //[ RUN ] DemoTestCase1.DemoTest1
+ //[ OK ] DemoTestCase1.DemoTest1 (0 ms)
+ //[ RUN ] DemoTestCase1.DemoTest2
+ //[ OK ] DemoTestCase1.DemoTest2 (0 ms)
+ //[----------] 2 tests from DemoTestCase1 (0 ms total)
+ //
+ //[----------] 2 tests from DemoTestCase2
+ //[ RUN ] DemoTestCase2.DemoTest1
+ //[ OK ] DemoTestCase2.DemoTest1 (0 ms)
+ //[ RUN ] DemoTestCase2.DemoTest2
+ //[ OK ] DemoTestCase2.DemoTest2 (0 ms)
+ //[----------] 2 tests from DemoTestCase2 (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 4 tests from 2 test cases ran. (0 ms total)
+ //[ PASSED ] 4 tests.
+ public void testAFewTestCasesWithTheSameNameInDifferentTestSuites() {
+ mockModelUpdater.skipCalls("setTestStatus");
+ mockModelUpdater.skipCalls("setTestingTime");
+
+ mockModelUpdater.enterTestSuite("DemoTestCase1");
+ mockModelUpdater.enterTestCase("DemoTest1");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("DemoTest2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.enterTestSuite("DemoTestCase2");
+ mockModelUpdater.enterTestCase("DemoTest1");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("DemoTest2");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 4 tests from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 4 tests from DemoTestCase
+ //[ RUN ] DemoTestCase.TestPass
+ //[ OK ] DemoTestCase.TestPass (0 ms)
+ //[ RUN ] DemoTestCase.TestFail
+ //demo_file.cc:38: Failure
+ //Value of: 2
+ //Expected: 1
+ //[ FAILED ] DemoTestCase.TestFail (0 ms)
+ //[ RUN ] DemoTestCase.TestAFewFails
+ //demo_file.cc:42: Failure
+ //Value of: 2
+ //Expected: 1
+ //demo_file.cc:43: Failure
+ //Value of: 2
+ //Expected: 1
+ //[ FAILED ] DemoTestCase.TestAFewFails (0 ms)
+ //[ RUN ] DemoTestCase.TestCustomFails
+ //demo_file.cc:47: Failure
+ //Failed
+ //Custom fatal fail!
+ //demo_file.cc:48: Failure
+ //Failed
+ //Another custom fatal fail!
+ //demo_file.cc:49: Failure
+ //Failed
+ //Yet another custom fatal fail!
+ //[ FAILED ] DemoTestCase.TestCustomFails (0 ms)
+ //[----------] 4 tests from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 4 tests from 1 test case ran. (1 ms total)
+ //[ PASSED ] 1 test.
+ //[ FAILED ] 3 tests, listed below:
+ //[ FAILED ] DemoTestCase.TestFail
+ //[ FAILED ] DemoTestCase.TestAFewFails
+ //[ FAILED ] DemoTestCase.TestCustomFails
+ //
+ // 3 FAILED TESTS
+ public void testDifferentTestStatuses() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("exitTestSuite");
+ mockModelUpdater.skipCalls("setTestingTime");
+
+ mockModelUpdater.enterTestCase("TestPass");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("TestFail");
+ mockModelUpdater.addTestMessage("demo_file.cc", 38, ITestMessage.Level.Error, "Value of: 2"+EOL+"Expected: 1");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("TestAFewFails");
+ mockModelUpdater.addTestMessage("demo_file.cc", 42, ITestMessage.Level.Error, "Value of: 2"+EOL+"Expected: 1");
+ mockModelUpdater.addTestMessage("demo_file.cc", 43, ITestMessage.Level.Error, "Value of: 2"+EOL+"Expected: 1");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("TestCustomFails");
+ mockModelUpdater.addTestMessage("demo_file.cc", 47, ITestMessage.Level.Error, "Failed"+EOL+"Custom fatal fail!");
+ mockModelUpdater.addTestMessage("demo_file.cc", 48, ITestMessage.Level.Error, "Failed"+EOL+"Another custom fatal fail!");
+ mockModelUpdater.addTestMessage("demo_file.cc", 49, ITestMessage.Level.Error, "Failed"+EOL+"Yet another custom fatal fail!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 2 tests from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 2 tests from DemoTestCase
+ //[ RUN ] DemoTestCase.TestWithSimpleTrace
+ //demo_file.cc:36: Failure
+ //Value of: 2
+ //Expected: 1
+ //Google Test trace:
+ //demo_file.cc:41: Trace point #2 in TestWithSimpleTrace
+ //demo_file.cc:40: Trace point #1 in TestWithSimpleTrace
+ //[ FAILED ] DemoTestCase.TestWithSimpleTrace (1 ms)
+ //[ RUN ] DemoTestCase.TestTraceForMultipleFails
+ //demo_file.cc:36: Failure
+ //Value of: 2
+ //Expected: 1
+ //Google Test trace:
+ //demo_file.cc:46: Trace point #1 in TestTraceForMultipleFails
+ //demo_file.cc:36: Failure
+ //Value of: 2
+ //Expected: 1
+ //Google Test trace:
+ //demo_file.cc:48: Trace point #2 in TestTraceForMultipleFails
+ //demo_file.cc:46: Trace point #1 in TestTraceForMultipleFails
+ //[ FAILED ] DemoTestCase.TestTraceForMultipleFails (0 ms)
+ //[----------] 2 tests from DemoTestCase (1 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 2 tests from 1 test case ran. (1 ms total)
+ //[ PASSED ] 0 tests.
+ //[ FAILED ] 2 tests, listed below:
+ //[ FAILED ] DemoTestCase.TestWithSimpleTrace
+ //[ FAILED ] DemoTestCase.TestTraceForMultipleFails
+ //
+ // 2 FAILED TESTS
+ public void testScopedTraceSupport() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("exitTestSuite");
+ mockModelUpdater.skipCalls("setTestingTime");
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestCase("TestWithSimpleTrace");
+ mockModelUpdater.addTestMessage("demo_file.cc", 36, ITestMessage.Level.Error, "Value of: 2"+EOL+"Expected: 1");
+ mockModelUpdater.addTestMessage("demo_file.cc", 41, ITestMessage.Level.Info, "Trace point #2 in TestWithSimpleTrace");
+ mockModelUpdater.addTestMessage("demo_file.cc", 40, ITestMessage.Level.Info, "Trace point #1 in TestWithSimpleTrace");
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("TestTraceForMultipleFails");
+ mockModelUpdater.addTestMessage("demo_file.cc", 36, ITestMessage.Level.Error, "Value of: 2"+EOL+"Expected: 1");
+ mockModelUpdater.addTestMessage("demo_file.cc", 46, ITestMessage.Level.Info, "Trace point #1 in TestTraceForMultipleFails");
+ mockModelUpdater.addTestMessage("demo_file.cc", 36, ITestMessage.Level.Error, "Value of: 2"+EOL+"Expected: 1");
+ mockModelUpdater.addTestMessage("demo_file.cc", 48, ITestMessage.Level.Info, "Trace point #2 in TestTraceForMultipleFails");
+ mockModelUpdater.addTestMessage("demo_file.cc", 46, ITestMessage.Level.Info, "Trace point #1 in TestTraceForMultipleFails");
+ mockModelUpdater.exitTestCase();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.TestMessageLocationFormats
+ //demo_file_name2.cpp:40: Failure
+ //Standard format with file name & line number
+ //unknown file:41: Failure
+ //Standard format with unknown file name
+ //demo_file_name2.cpp(42): Failure
+ //VS-like format with file name & line number
+ //unknown file(43): Failure
+ //VS-like format with unknown file name
+ //demo_file_name2.cpp: Failure
+ //Location with unknown line number
+ //unknown file: Failure
+ //Location with unknown file name & line number
+ //[ FAILED ] DemoTestCase.TestMessageLocationFormats (1 ms)
+ //[----------] 1 test from DemoTestCase (1 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (1 ms total)
+ //[ PASSED ] 0 tests.
+ //[ FAILED ] 1 test, listed below:
+ //[ FAILED ] DemoTestCase.TestMessageLocationFormats
+ //
+ // 1 FAILED TEST
+ public void testDifferentLocationsFormatsWithStandardMessageFormat() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("exitTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ mockModelUpdater.skipCalls("exitTestCase");
+ mockModelUpdater.skipCalls("setTestingTime");
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.addTestMessage("demo_file_name2.cpp", 40, ITestMessage.Level.Error, "Standard format with file name & line number");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, 41, ITestMessage.Level.Error, "Standard format with unknown file name");
+ mockModelUpdater.addTestMessage("demo_file_name2.cpp", 42, ITestMessage.Level.Error, "VS-like format with file name & line number");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, 43, ITestMessage.Level.Error, "VS-like format with unknown file name");
+ mockModelUpdater.addTestMessage("demo_file_name2.cpp", DEFAULT_LOCATION_LINE, ITestMessage.Level.Error, "Location with unknown line number");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Error, "Location with unknown file name & line number");
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.TestMessageLocationFormats
+ //demo_file_name2.cpp:40: error: Standard format with file name & line number
+ //unknown file:41: error: Standard format with unknown file name
+ //demo_file_name2.cpp(42): error: VS-like format with file name & line number
+ //unknown file(43): error: VS-like format with unknown file name
+ //demo_file_name2.cpp: error: Location with unknown line number
+ //unknown file: error: Location with unknown file name & line number
+ //[ FAILED ] DemoTestCase.TestMessageLocationFormats (1 ms)
+ //[----------] 1 test from DemoTestCase (1 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (1 ms total)
+ //[ PASSED ] 0 tests.
+ //[ FAILED ] 1 test, listed below:
+ //[ FAILED ] DemoTestCase.TestMessageLocationFormats
+ //
+ // 1 FAILED TEST
+ public void testDifferentLocationsFormatsWithVSLikeMessageFormat() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("exitTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ mockModelUpdater.skipCalls("exitTestCase");
+ mockModelUpdater.skipCalls("setTestingTime");
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.addTestMessage("demo_file_name2.cpp", 40, ITestMessage.Level.Error, "Standard format with file name & line number");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, 41, ITestMessage.Level.Error, "Standard format with unknown file name");
+ mockModelUpdater.addTestMessage("demo_file_name2.cpp", 42, ITestMessage.Level.Error, "VS-like format with file name & line number");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, 43, ITestMessage.Level.Error, "VS-like format with unknown file name");
+ mockModelUpdater.addTestMessage("demo_file_name2.cpp", DEFAULT_LOCATION_LINE, ITestMessage.Level.Error, "Location with unknown line number");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Error, "Location with unknown file name & line number");
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.TestMultiLineMessage
+ //demo_file.cc:40: Failure
+ //Line 1
+ //Line 2
+ //Line 3
+ //[ FAILED ] DemoTestCase.TestMultiLineMessage (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 0 tests.
+ //[ FAILED ] 1 test, listed below:
+ //[ FAILED ] DemoTestCase.TestMultiLineMessage
+ //
+ // 1 FAILED TEST
+ public void testMultiLineMessage() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("exitTestSuite");
+ mockModelUpdater.skipCalls("setTestingTime");
+ mockModelUpdater.skipCalls("setTestStatus");
+
+ mockModelUpdater.enterTestCase("TestMultiLineMessage");
+ mockModelUpdater.addTestMessage("demo_file.cc", 40, ITestMessage.Level.Error, "Line 1"+EOL+"Line 2"+EOL+"Line 3");
+ mockModelUpdater.exitTestCase();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 2 tests from 2 test cases.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase1
+ //[ RUN ] DemoTestCase1.Test1
+ //unknown file: Failure
+ //Unknown C++ exception thrown in the test body.
+ //[ FAILED ] DemoTestCase1.Test1 (1000 ms)
+ //[----------] 1 test from DemoTestCase1 (1000 ms total)
+ //
+ //[----------] 1 test from DemoTestCase2
+ //[ RUN ] DemoTestCase2.Test2
+ //[ OK ] DemoTestCase2.Test2 (2000 ms)
+ //[----------] 1 test from DemoTestCase2 (2000 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 2 tests from 2 test cases ran. (3000 ms total)
+ //[ PASSED ] 1 test.
+ //[ FAILED ] 1 test, listed below:
+ //[ FAILED ] DemoTestCase1.Test1
+ //
+ // 1 FAILED TEST
+ public void testTestingTimeSupport() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("exitTestSuite");
+ mockModelUpdater.skipCalls("setTestStatus");
+ mockModelUpdater.skipCalls("addTestMessage");
+
+ mockModelUpdater.enterTestCase("Test1");
+ mockModelUpdater.setTestingTime(1000);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("Test2");
+ mockModelUpdater.setTestingTime(2000);
+ mockModelUpdater.exitTestCase();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 3 tests from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 3 tests from Inst/DemoTestCase
+ //[ RUN ] Inst/DemoTestCase.Test/0
+ //demo_file.cc:50: Failure
+ //Failed
+ //Param1
+ //[ FAILED ] Inst/DemoTestCase.Test/0, where GetParam() = "Param1" (0 ms)
+ //[ RUN ] Inst/DemoTestCase.Test/1
+ //[ OK ] Inst/DemoTestCase.Test/1 (0 ms)
+ //[ RUN ] Inst/DemoTestCase.Test/2
+ //demo_file.cc:50: Failure
+ //Failed
+ //Param3
+ //[ FAILED ] Inst/DemoTestCase.Test/2, where GetParam() = "Param3" (0 ms)
+ //[----------] 3 tests from Inst/DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 3 tests from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ //[ FAILED ] 2 tests, listed below:
+ //[ FAILED ] Inst/DemoTestCase.Test/0, where GetParam() = "Param1"
+ //[ FAILED ] Inst/DemoTestCase.Test/2, where GetParam() = "Param3"
+ //
+ // 2 FAILED TESTS
+ public void testParametrizedTestsSupport() {
+ mockModelUpdater.enterTestSuite("Inst/DemoTestCase");
+ mockModelUpdater.enterTestCase("Test/0");
+ mockModelUpdater.addTestMessage("demo_file.cc", 50, ITestMessage.Level.Error, "Failed"+EOL+"Param1");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Info, "Instantiated with GetParam() = \"Param1\"");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("Test/1");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("Test/2");
+ mockModelUpdater.addTestMessage("demo_file.cc", 50, ITestMessage.Level.Error, "Failed"+EOL+"Param3");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Info, "Instantiated with GetParam() = \"Param3\"");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from Inst/DemoTestCase
+ //[ RUN ] Inst/DemoTestCase.Test/0
+ //demo_file.cc:50: Failure
+ //Failed
+ //[ FAILED ] Inst/DemoTestCase.Test/0, where GetParam() = 0x4f50cc (0 ms)
+ //[----------] 1 test from Inst/DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 0 tests.
+ //[ FAILED ] 1 test, listed below:
+ //[ FAILED ] Inst/DemoTestCase.Test/0, where GetParam() = 0x4f50cc
+ //
+ // 2 FAILED TESTS
+ public void testParametrizedTestsWithoutQuotesSupport() {
+ mockModelUpdater.enterTestSuite("Inst/DemoTestCase");
+ mockModelUpdater.enterTestCase("Test/0");
+ mockModelUpdater.addTestMessage("demo_file.cc", 50, ITestMessage.Level.Error, "Failed");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Info, "Instantiated with GetParam() = 0x4f50cc");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 3 tests from 3 test cases.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase/0, where TypeParam = char
+ //[ RUN ] DemoTestCase/0.Test
+ //demo_file.cc:60: Failure
+ //Failed
+ //char type
+ //[ FAILED ] DemoTestCase/0.Test, where TypeParam = char (0 ms)
+ //[----------] 1 test from DemoTestCase/0 (0 ms total)
+ //
+ //[----------] 1 test from DemoTestCase/1, where TypeParam = int
+ //[ RUN ] DemoTestCase/1.Test
+ //[ OK ] DemoTestCase/1.Test (0 ms)
+ //[----------] 1 test from DemoTestCase/1 (0 ms total)
+ //
+ //[----------] 1 test from DemoTestCase/2, where TypeParam = unsigned int
+ //[ RUN ] DemoTestCase/2.Test
+ //demo_file.cc:60: Failure
+ //Failed
+ //unsigned int type
+ //[ FAILED ] DemoTestCase/2.Test, where TypeParam = unsigned int (0 ms)
+ //[----------] 1 test from DemoTestCase/2 (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 3 tests from 3 test cases ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ //[ FAILED ] 2 tests, listed below:
+ //[ FAILED ] DemoTestCase/0.Test, where TypeParam = char
+ //[ FAILED ] DemoTestCase/2.Test, where TypeParam = unsigned int
+ //
+ // 2 FAILED TESTS
+ public void testTypedTestsSupport() {
+ mockModelUpdater.enterTestSuite("DemoTestCase/0(char)");
+ mockModelUpdater.enterTestCase("Test");
+ mockModelUpdater.addTestMessage("demo_file.cc", 60, ITestMessage.Level.Error, "Failed"+EOL+"char type");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.enterTestSuite("DemoTestCase/1(int)");
+ mockModelUpdater.enterTestCase("Test");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ mockModelUpdater.enterTestSuite("DemoTestCase/2(unsigned int)");
+ mockModelUpdater.enterTestCase("Test");
+ mockModelUpdater.addTestMessage("demo_file.cc", 60, ITestMessage.Level.Error, "Failed"+EOL+"unsigned int type");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //Unknown line in the output
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //Another unknown line in the output
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest
+ //Yet another unknown line in the output
+ //[ OK ] DemoTestCase.DemoTest (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //One more unknown line in the output
+ //
+ //[----------] Global test environment tear-down
+ //And one more unknown line in the output
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ public void testAllUnrecognizedLinesShouldBeSkipped() {
+ mockModelUpdater.enterTestSuite("DemoTestCase");
+ mockModelUpdater.enterTestCase("DemoTest");
+ mockModelUpdater.setTestingTime(0);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //
+ public void testNoInput() {
+ // NOTE: The comment above is left blank intentionally
+ expectTestingException();
+ }
+
+
+ // This is not an input from a Google Test Module
+ public void testAbsolutelyIncorrectInput() {
+ expectTestingException();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] Not_A_DemoTestCase.DemoTest
+ public void testUnexpectedOutputEnd() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+
+ expectTestingException();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] Not_A_DemoTestCase.DemoTest
+ //[ OK ] DemoTestCase.DemoTest (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ public void testTestSuiteNameMismatch1() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+
+ expectTestingException();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest
+ //[ OK ] Not_A_DemoTestCase.DemoTest (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ public void testTestSuiteNameMismatch2() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+
+ expectTestingException();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest
+ //[ OK ] DemoTestCase.DemoTest (0 ms)
+ //[----------] 1 test from Not_A_DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ public void testTestSuiteNameMismatch3() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ mockModelUpdater.skipCalls("setTestingTime");
+ mockModelUpdater.skipCalls("setTestStatus");
+ mockModelUpdater.skipCalls("exitTestCase");
+
+ expectTestingException();
+ }
+
+
+ //Running main() from gtest_main.cc
+ //[==========] Running 1 test from 1 test case.
+ //[----------] Global test environment set-up.
+ //[----------] 1 test from DemoTestCase
+ //[ RUN ] DemoTestCase.DemoTest
+ //[ OK ] DemoTestCase.NOT_A_DemoTest (0 ms)
+ //[----------] 1 test from DemoTestCase (0 ms total)
+ //
+ //[----------] Global test environment tear-down
+ //[==========] 1 test from 1 test case ran. (0 ms total)
+ //[ PASSED ] 1 test.
+ public void testTestCaseNameMismatch() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+
+ expectTestingException();
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/MockTestModelUpdater.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/MockTestModelUpdater.java
new file mode 100644
index 0000000000..218284173d
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/MockTestModelUpdater.java
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.testsrunners;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.eclipse.cdt.testsrunner.model.IModelVisitor;
+import org.eclipse.cdt.testsrunner.model.ITestCase;
+import org.eclipse.cdt.testsrunner.model.ITestItem;
+import org.eclipse.cdt.testsrunner.model.ITestItem.Status;
+import org.eclipse.cdt.testsrunner.model.ITestMessage;
+import org.eclipse.cdt.testsrunner.model.ITestMessage.Level;
+import org.eclipse.cdt.testsrunner.model.ITestModelUpdater;
+import org.eclipse.cdt.testsrunner.model.ITestSuite;
+
+/**
+ * Mock for the {@see ITestModelUpdater}.
+ */
+@SuppressWarnings("nls")
+public class MockTestModelUpdater implements ITestModelUpdater {
+
+ private class FakeTestItem implements ITestItem {
+
+ private String name = null;
+
+ protected void unexpectedMethodCall() {
+ Assert.fail("Unexpected method call");
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void resetName() {
+ name = null;
+ }
+
+ // Unimplemented methods
+ @Override
+ public Status getStatus() { unexpectedMethodCall(); return null; }
+ @Override
+ public int getTestingTime() { unexpectedMethodCall(); return 0; }
+ @Override
+ public ITestSuite getParent() { unexpectedMethodCall(); return null; }
+ @Override
+ public boolean hasChildren() { unexpectedMethodCall(); return false; }
+ @Override
+ public ITestItem[] getChildren() { unexpectedMethodCall(); return null; }
+ @Override
+ public void visit(IModelVisitor visitor) { unexpectedMethodCall(); }
+ }
+
+ private class FakeTestCase extends FakeTestItem implements ITestCase {
+ @Override
+ public ITestMessage[] getTestMessages() { unexpectedMethodCall(); return null; }
+ }
+
+ private class FakeTestSuite extends FakeTestItem implements ITestSuite {
+ }
+
+
+ private class MethodInfo {
+
+ private String methodName;
+ private Object[] args;
+
+ MethodInfo(String methodName, Object[] args) {
+ this.methodName = methodName;
+ this.args = args;
+ }
+
+ private String genArgs(String methodName, Object[] args) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(methodName);
+ sb.append("(");
+ boolean needDelimited = false;
+ for (Object arg : args) {
+ if (needDelimited) {
+ sb.append(", ");
+ } else {
+ needDelimited = true;
+ }
+ if (arg != null) {
+ sb.append('"');
+ sb.append(arg.toString());
+ sb.append('"');
+ } else {
+ sb.append("null");
+ }
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void check(String methodName, Object[] args) {
+ if (!this.methodName.equals(methodName)) {
+ Assert.failNotEquals("Unexpected method call. ",
+ genArgs(this.methodName, this.args), genArgs(methodName, args));
+ }
+ boolean compareFailed = (this.args.length != args.length);
+ if (!compareFailed) {
+ for (int i = 0; i < args.length; i++) {
+ if (this.args[i] == null) {
+ if (args[i] != null) {
+ compareFailed = true;
+ break;
+ }
+ } else if (!this.args[i].equals(args[i])) {
+ compareFailed = true;
+ break;
+ }
+ }
+ }
+ if (compareFailed) {
+ Assert.failNotEquals("Unexpected parameters of method "+this.methodName+"(). ",
+ genArgs(this.methodName, this.args), genArgs(methodName, args));
+ }
+ }
+ }
+
+
+ private LinkedList<MethodInfo> methodCalls = new LinkedList<MethodInfo>();
+ private boolean replayMode = false;
+ private Set<String> skippedMethods = new HashSet<String>();
+
+ // NOTE: Test suites nesting is not supported yet cause there is no need in it
+ private FakeTestSuite currentTestSuite = new FakeTestSuite();
+ private FakeTestCase currentTestCase = new FakeTestCase();
+
+
+ @Override
+ public void enterTestSuite(String name) {
+ genericImpl("enterTestSuite", name);
+ // NOTE: Test suites or cases nesting is not supported for mocking
+ currentTestSuite.setName(name);
+ }
+
+ @Override
+ public void exitTestSuite() {
+ genericImpl("exitTestSuite");
+ currentTestSuite.resetName();
+ }
+
+ @Override
+ public void enterTestCase(String name) {
+ genericImpl("enterTestCase", name);
+ currentTestCase.setName(name);
+ }
+
+
+ @Override
+ public void setTestStatus(Status status) {
+ genericImpl("setTestStatus", status);
+ }
+
+ @Override
+ public void setTestingTime(int testingTime) {
+ genericImpl("setTestingTime", testingTime);
+ }
+
+ @Override
+ public void exitTestCase() {
+ genericImpl("exitTestCase");
+ currentTestCase.resetName();
+ }
+
+ @Override
+ public void addTestMessage(String file, int line, Level level, String text) {
+ genericImpl("addTestMessage", file, line, level, text);
+ }
+
+ @Override
+ public ITestSuite currentTestSuite() {
+ return currentTestSuite;
+ }
+
+ @Override
+ public ITestCase currentTestCase() {
+ return currentTestCase;
+ }
+
+ public void skipCalls(String methodName) {
+ skippedMethods.add(methodName);
+ }
+
+ public void replay() {
+ replayMode = true;
+ }
+
+ private void genericImpl(String methodName, Object... args) {
+ if (!skippedMethods.contains(methodName)) {
+ if (replayMode) {
+ if (methodCalls.isEmpty()) {
+ Assert.fail("Unexpected method call "+methodName+"()");
+ } else {
+ methodCalls.pollFirst().check(methodName, args);
+ }
+ } else {
+ methodCalls.addLast(new MethodInfo(methodName, args));
+ }
+ }
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/QtTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/QtTestCase.java
new file mode 100644
index 0000000000..b5dc9dc8f5
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/src/org/eclipse/cdt/testsrunner/testsrunners/QtTestCase.java
@@ -0,0 +1,693 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.testsrunner.testsrunners;
+
+import java.text.MessageFormat;
+
+import org.eclipse.cdt.testsrunner.internal.qttest.QtTestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider;
+import org.eclipse.cdt.testsrunner.model.ITestItem;
+import org.eclipse.cdt.testsrunner.model.ITestMessage;
+
+
+/**
+ * Test for {@see QtTestsRunner} class
+ */
+@SuppressWarnings("nls")
+public class QtTestCase extends BaseTestCase {
+
+ private static final String DEFAULT_LOCATION_FILE = "";
+ private static final int DEFAULT_LOCATION_LINE = 0;
+
+ @Override
+ protected ITestsRunnerProvider createTestsRunner() {
+ return new QtTestsRunnerProvider();
+ }
+
+
+ private void addStandardBenchmarkMessage(int value, String units, int iterations) {
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Info,
+ MessageFormat.format("{0,number,#.####} {1} per iteration (total: {2}, iterations: {3})",
+ ((float)value)/iterations, units, value, iterations)
+ );
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testNoCustomTestCases() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testTheOnlyPassingCustomTestCase() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<Incident type="fail" file="qt_test_demo.cpp" line="6">
+ // <Description><![CDATA[Compared values are not the same
+ // Actual (1): 1
+ // Expected (2): 2]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testTheOnlyFailingCustomTestCase() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 6, ITestMessage.Level.FatalError,
+ "Compared values are not the same\n Actual (1): 1\n Expected (2): 2");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<Incident type="fail" file="qtestcase.cpp" line="1675">
+ // <Description><![CDATA[Caught unhandled exception]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //</TestCase>
+ public void testTheOnlyAbortedCustomTestCase() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo");
+ mockModelUpdater.addTestMessage("qtestcase.cpp", 1675, ITestMessage.Level.FatalError,
+ "Caught unhandled exception");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ // NOTE: Qt.Test does not run any other test cases after exception throwing in a test case
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testWarning">
+ //<Message type="warn" file="" line="0">
+ // <Description><![CDATA[Test warning!]]></Description>
+ //</Message>
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testFailure">
+ //<Incident type="fail" file="qt_test_demo.cpp" line="41">
+ // <Description><![CDATA[Test fail!]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="testSkip">
+ //<Message type="skip" file="qt_test_demo.cpp" line="47">
+ // <Description><![CDATA[Test skip!]]></Description>
+ //</Message>
+ //</TestFunction>
+ //<TestFunction name="testExpectedFailWithContinue">
+ //<Incident type="xfail" file="qt_test_demo.cpp" line="60">
+ // <Description><![CDATA[Will fix in the next release]]></Description>
+ //</Incident>
+ //<Incident type="fail" file="qt_test_demo.cpp" line="61">
+ // <Description><![CDATA[Failed!]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="testExpectedFailWithAbort">
+ //<Incident type="xfail" file="qt_test_demo.cpp" line="68">
+ // <Description><![CDATA[Will fix in the next release]]></Description>
+ //</Incident>
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testExpectedFailPassed">
+ //<Incident type="xpass" file="qt_test_demo.cpp" line="70">
+ // <Description><![CDATA[COMPARE()]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="testUnknownIncidentType">
+ //<Incident type="??????" file="qt_test_demo.cpp" line="72">
+ // <Description><![CDATA[Unknown incident test!]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="testUnknownMessageType">
+ //<Message type="??????" file="qt_test_demo.cpp" line="80">
+ // <Description><![CDATA[Unknown message type test!]]></Description>
+ //</Message>
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testDifferentMessageLevels() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testWarning");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Warning, "Test warning!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testFailure");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 41, ITestMessage.Level.FatalError, "Test fail!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testSkip");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 47, ITestMessage.Level.Info, "Test skip!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Skipped);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testExpectedFailWithContinue");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 60, ITestMessage.Level.Error, "Will fix in the next release");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 61, ITestMessage.Level.FatalError, "Failed!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testExpectedFailWithAbort");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 68, ITestMessage.Level.Error, "Will fix in the next release");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testExpectedFailPassed");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 70, ITestMessage.Level.Error, "COMPARE()");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testUnknownIncidentType");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 72, ITestMessage.Level.FatalError, "Unknown incident test!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Aborted);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testUnknownMessageType");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 80, ITestMessage.Level.FatalError, "Unknown message type test!");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<BenchmarkResult metric="walltime" tag="" value="28" iterations="8192" />
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testBenchmarkBasicSupport() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo");
+ addStandardBenchmarkMessage(28, "msec", 8192);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<BenchmarkResult metric="callgrind" tag="locale aware compare" value="30" iterations="8192" />
+ //<BenchmarkResult metric="callgrind" tag="standard compare" value="24" iterations="10485" />
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testBenchmarkWithDataTag() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(locale aware compare)");
+ addStandardBenchmarkMessage(30, "instr.", 8192);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(standard compare)");
+ addStandardBenchmarkMessage(24, "instr.", 10485);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<Incident type="fail" file="qt_test_demo.cpp" line="57">
+ // <DataTag><![CDATA[locale aware compare]]></DataTag>
+ // <Description><![CDATA[Failed!]]></Description>
+ //</Incident>
+ //<Incident type="fail" file="qt_test_demo.cpp" line="57">
+ // <DataTag><![CDATA[locale aware compare]]></DataTag>
+ // <Description><![CDATA[Failed!]]></Description>
+ //</Incident>
+ //<BenchmarkResult metric="cputicks" tag="locale aware compare" value="29" iterations="8192" />
+ //<Incident type="fail" file="qt_test_demo.cpp" line="58">
+ // <DataTag><![CDATA[standard compare]]></DataTag>
+ // <Description><![CDATA[Failed!]]></Description>
+ //</Incident>
+ //<Incident type="fail" file="qt_test_demo.cpp" line="58">
+ // <DataTag><![CDATA[standard compare]]></DataTag>
+ // <Description><![CDATA[Failed!]]></Description>
+ //</Incident>
+ //<BenchmarkResult metric="cputicks" tag="standard compare" value="24" iterations="10485" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testBenchmarkMixedWithIncidentsWithDataTag() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(locale aware compare)");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 57, ITestMessage.Level.FatalError, "Failed!");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 57, ITestMessage.Level.FatalError, "Failed!");
+ addStandardBenchmarkMessage(29, "ticks", 8192);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(standard compare)");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 58, ITestMessage.Level.FatalError, "Failed!");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 58, ITestMessage.Level.FatalError, "Failed!");
+ addStandardBenchmarkMessage(24, "ticks", 10485);
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<Incident type="fail" file="qt_test_demo.cpp" line="20">
+ // <DataTag><![CDATA[all lower]]></DataTag>
+ // <Description><![CDATA[Compared values are not the same
+ // Actual (string.toUpper()): HELLO
+ // Expected (result): HELLO2]]></Description>
+ //</Incident>
+ //<Incident type="fail" file="qt_test_demo.cpp" line="20">
+ // <DataTag><![CDATA[mixed]]></DataTag>
+ // <Description><![CDATA[Compared values are not the same
+ // Actual (string.toUpper()): HELLO
+ // Expected (result): HELLO3]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testIncidentWithDataTag() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(all lower)");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 20, ITestMessage.Level.FatalError,
+ "Compared values are not the same\n Actual (string.toUpper()): HELLO\n Expected (result): HELLO2");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(mixed)");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 20, ITestMessage.Level.FatalError,
+ "Compared values are not the same\n Actual (string.toUpper()): HELLO\n Expected (result): HELLO3");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testDemo">
+ //<Message type="warn" file="" line="0">
+ // <DataTag><![CDATA[all lower]]></DataTag>
+ // <Description><![CDATA[hello]]></Description>
+ //</Message>
+ //<Incident type="fail" file="qt_test_demo.cpp" line="66">
+ // <DataTag><![CDATA[all lower]]></DataTag>
+ // <Description><![CDATA[HELLO2]]></Description>
+ //</Incident>
+ //<Message type="warn" file="" line="0">
+ // <DataTag><![CDATA[mixed]]></DataTag>
+ // <Description><![CDATA[Hello]]></Description>
+ //</Message>
+ //<Incident type="fail" file="qt_test_demo.cpp" line="66">
+ // <DataTag><![CDATA[mixed]]></DataTag>
+ // <Description><![CDATA[HELLO3]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testMessageWithDataTag() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(all lower)");
+ mockModelUpdater.addTestMessage("", 0, ITestMessage.Level.Warning, "hello");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 66, ITestMessage.Level.FatalError, "HELLO2");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testDemo(mixed)");
+ mockModelUpdater.addTestMessage("", 0, ITestMessage.Level.Warning, "Hello");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 66, ITestMessage.Level.FatalError, "HELLO3");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testWithEmptyIncident">
+ //<Incident type="fail" file="qt_test_demo.cpp" line="6">
+ // <Description><![CDATA[]]></Description>
+ //</Incident>
+ //</TestFunction>
+ //<TestFunction name="testWithEmptyMessage">
+ //<Message type="warn" file="" line="0">
+ // <Description><![CDATA[]]></Description>
+ //</Message>
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testWithEmptyMessage() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testWithEmptyIncident");
+ mockModelUpdater.addTestMessage("qt_test_demo.cpp", 6, ITestMessage.Level.FatalError, "");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Failed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testWithEmptyMessage");
+ mockModelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Warning, "");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //<TestFunction name="testWithoutAnyIncidents">
+ //</TestFunction>
+ //<TestFunction name="cleanupTestCase">
+ //<Incident type="pass" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testWithoutAnyIncidents() {
+ mockModelUpdater.enterTestSuite("MainTS");
+ mockModelUpdater.enterTestCase("initTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("testWithoutAnyIncidents");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.enterTestCase("cleanupTestCase");
+ mockModelUpdater.setTestStatus(ITestItem.Status.Passed);
+ mockModelUpdater.exitTestCase();
+ mockModelUpdater.exitTestSuite();
+ }
+
+
+ //
+ public void testNoInput() {
+ // NOTE: The comment above is left blank intentionally
+ expectTestingException();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2 <!-- QTestVersion is not closed -->
+ //</Environment>
+ //</TestCase>
+ public void testBadFormedXml() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ expectTestingException();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ public void testUnexceptedXmlEnd() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ expectTestingException();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="some_wrong_value" file="" line="0" />
+ //</TestFunction>
+ //</TestCase>
+ public void testBadIncidentTypeValue() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Message type="some_wrong_value" file="" line="0">
+ // <Description><![CDATA[Test warning!]]></Description>
+ //</Message>
+ //</TestFunction>
+ //</TestCase>
+ public void testBadMessageTypeValue() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Incident type="some_wrong_value" file="" line="<wrong_value>" />
+ //</TestFunction>
+ //</TestCase>
+ public void testBadLineNumberValueOfIncident() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="initTestCase">
+ //<Message type="warn" file="" line="<wrong_value>">
+ // <Description><![CDATA[Test warning!]]></Description>
+ //</Message>
+ //</TestFunction>
+ //</TestCase>
+ public void testBadLineNumberValueOfMessage() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+ //<?xml version="1.0" encoding="ISO-8859-1"?>
+ //<TestCase name="MainTS">
+ //<Environment>
+ // <QtVersion>4.6.2</QtVersion>
+ // <QTestVersion>4.6.2</QTestVersion>
+ //</Environment>
+ //<TestFunction name="testDemo">
+ //<BenchmarkResult metric="<wrong_value>" tag="" value="28" iterations="8192" />
+ //</TestFunction>
+ //</TestCase>
+ public void testBadBenchmarkMetricValue() {
+ mockModelUpdater.skipCalls("enterTestSuite");
+ mockModelUpdater.skipCalls("enterTestCase");
+ expectTestingException();
+ }
+
+}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.test/test.xml b/testsrunner/org.eclipse.cdt.testsrunner.test/test.xml
new file mode 100644
index 0000000000..eed63892c1
--- /dev/null
+++ b/testsrunner/org.eclipse.cdt.testsrunner.test/test.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <property name="eclipse-home" value="${basedir}"/>
+
+ <!-- This is the default name of the org.eclipse.test plugin. -->
+ <!-- We need to be able to override this for the case where the -->
+ <!-- org.eclipse.test plugin was build as part of a feature and -->
+ <!-- will have a name similar to org.eclipse.test_2.1.0 -->
+ <property name="org.eclipse.test" value="org.eclipse.test"/>
+ <!-- sets the properties eclipse-home, and library-file -->
+ <property name="plugin-name" value="org.eclipse.cdt.testsrunner.test"/>
+ <property name="library-file"
+ value="${eclipse-home}/plugins/${org.eclipse.test}/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="cdt-folder"
+ value="${eclipse-home}/cdt_folder"/>
+ <delete dir="${cdt-folder}" quiet="true"/>
+ <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${cdt-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname"
+ value="org.eclipse.cdt.testsrunner.test.TestsRunnerSuite"/>
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+
+</project>

Back to the top