Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 82e00fc5529b670893e03c5b0e1f64099dda557b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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