Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2013-06-29 06:02:42 -0400
committerAndrew Gvozdev2013-06-29 06:06:44 -0400
commit310ad6c995c6c0359055a897964fad15486ac5f0 (patch)
tree85ce5f95fa6ef051f47eadd53d10fa711dbcfe8f
parent26e1ef645205bc5b5a34a9b9834277019580bb02 (diff)
downloadorg.eclipse.cdt-310ad6c995c6c0359055a897964fad15486ac5f0.tar.gz
org.eclipse.cdt-310ad6c995c6c0359055a897964fad15486ac5f0.tar.xz
org.eclipse.cdt-310ad6c995c6c0359055a897964fad15486ac5f0.zip
bug 411547: Added base test class with methods to get test name and test comments for org.eclipse.cdt.make.ui.tests
-rw-r--r--build/org.eclipse.cdt.make.ui.tests/META-INF/MANIFEST.MF3
-rw-r--r--build/org.eclipse.cdt.make.ui.tests/src/org/eclipse/cdt/make/ui/tests/MakeUITestBase.java63
2 files changed, 65 insertions, 1 deletions
diff --git a/build/org.eclipse.cdt.make.ui.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.ui.tests/META-INF/MANIFEST.MF
index 4f71f460e4..89b50decfa 100644
--- a/build/org.eclipse.cdt.make.ui.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.ui.tests/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Bundle-Activator: org.eclipse.cdt.make.ui.tests.MakeUITestsPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.cdt.make.ui,
- org.junit;bundle-version="4.10.0"
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.cdt.core.tests
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Eclipse.org
diff --git a/build/org.eclipse.cdt.make.ui.tests/src/org/eclipse/cdt/make/ui/tests/MakeUITestBase.java b/build/org.eclipse.cdt.make.ui.tests/src/org/eclipse/cdt/make/ui/tests/MakeUITestBase.java
new file mode 100644
index 0000000000..cca0e43d7f
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui.tests/src/org/eclipse/cdt/make/ui/tests/MakeUITestBase.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
+ * 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:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.tests;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+/**
+ * Base for unit testing of Make UI test suite.
+ */
+public class MakeUITestBase {
+ @Rule
+ public TestName testNameRule = new TestName();
+ private TestSourceReader commentReader;
+
+ /**
+ * Constructor.
+ */
+ protected MakeUITestBase() {
+ this("src");
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param srcRoot - project folder where the test package is rooted.
+ */
+ protected MakeUITestBase(String srcRoot) {
+ this.commentReader = new TestSourceReader(MakeUITestsPlugin.getDefault().getBundle(), srcRoot, this.getClass(), 1);
+ }
+
+ /**
+ * Get name of the current test method.
+ *
+ * @return Name of the current test method.
+ */
+ public String getName() {
+ return testNameRule.getMethodName();
+ }
+
+ /**
+ * Retrieve comments above the current test method.
+ *
+ * @return First section of comments above the current test method.
+ * A sections is defined as a block of comments starting with "//". Sections are separated by empty lines.
+ * @throws IOException
+ */
+ public StringBuilder getTestComments() throws IOException {
+ return commentReader.getContentsForTest(getName())[0];
+ }
+
+}

Back to the top