-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CodeChecker stub to the test resources
CodeChecker resources in a new shared project that both unit and integration test suites reach. org.codechecker.eclipse.rcp.shared For this to work, the unit test needed to be changed to "JUnit Plug-in test" Because cross bundle resource loading only works in an osgi context, which plain standard JUnit isn't. This results in a slightly slower execution, because an osgi context is needed to be created (basically a headless eclipse). This difference of execution time will diminish when the test case count rises in the unit tests. The benefit is much more flexible code maintainability. Also moved the checkstyle "fail on warning" switch to the root test folder, and explicitly allowed the unit tests to violate until future clean up. This way the new shared project is also protected as well as the integration tests. Commonly used functions like resource loading for the tests, or CodeChecker preparation can be reached from this module, as well as commonly used resources, like the new CodeChecker stub. The CodeChecker added in this commit is utilized the in the new Indicator test which is for to test the configuration indicator in the CodeChecker preferences page. This new Test is now a part of a test Suite: AllTests.java The common loading and workspace related works can be performed in this class. Added a lot of utility methods for navigating the eclipse gui.
- Loading branch information
Showing
26 changed files
with
769 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*.swo | ||
|
||
# Eclipse | ||
bin/ | ||
.idea | ||
*.iml | ||
target/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ source.. = src/ | |
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
fragment.xml | ||
fragment.xml,\ | ||
resources/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/AllTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.codechecker.eclipse.plugin; | ||
|
||
import org.codechecker.eclipse.plugin.utils.GuiUtils; | ||
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
/** | ||
* Test Suite for running the gui tests. Add your class to the Suite class list. | ||
*/ | ||
@RunWith(Suite.class) | ||
@SuiteClasses({ PluginTest.class, IndicatorTest.class }) | ||
public class AllTests { | ||
|
||
/** | ||
* Never called. | ||
*/ | ||
private AllTests() {} | ||
|
||
/** | ||
* Import cpp project into workspace, and setup SWTBot. | ||
* | ||
*/ | ||
@BeforeClass | ||
public static void setup() { | ||
//clearWs(); | ||
SWTWorkbenchBot bot = new SWTWorkbenchBot(); | ||
GuiUtils.closeWelcomeIfPresent(bot); | ||
GuiUtils.changePerspectiveTo(GuiUtils.C_CPP_PESPECTIVE, bot); | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
...rg.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/IndicatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package org.codechecker.eclipse.plugin; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.codechecker.eclipse.plugin.utils.GuiUtils; | ||
import org.codechecker.eclipse.rcp.shared.utils.Utils; | ||
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; | ||
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; | ||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel; | ||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; | ||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; | ||
import org.hamcrest.core.IsNull; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
/** | ||
* CodeChecker plugin preferences indicator tests. | ||
*/ | ||
public class IndicatorTest { | ||
|
||
private static final int SHORT_WAIT_TIME = 500; // in milliseconds | ||
|
||
private static final String CODECHECKER = "CodeChecker"; | ||
|
||
private static SWTWorkbenchBot bot; | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
private SWTBotShell preferencesShell; | ||
|
||
/** | ||
* Import cpp project into workspace, and setup SWTBot. | ||
* | ||
*/ | ||
@BeforeClass | ||
public static void setup() { | ||
bot = new SWTWorkbenchBot(); | ||
} | ||
|
||
/** | ||
* Open preferences, CodeChecker page before every test. | ||
*/ | ||
@Before | ||
public void openPreferences() { | ||
preferencesShell = GuiUtils.getPreferencesTab(CODECHECKER, bot); | ||
} | ||
|
||
/** | ||
* Test that with unconfigured CodeChecker, a warning message is displayed. | ||
*/ | ||
@Test | ||
public void testNoCodeCheckerFound() { | ||
SWTBotCLabel label = null; | ||
try { | ||
label = bot.clabel("CodeChecker package directory is invalid"); | ||
} catch (WidgetNotFoundException e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
assertThat("There was no invalid CodeChecker message displayed", label, is(IsNull.notNullValue())); | ||
|
||
preferencesShell.close(); | ||
} | ||
|
||
/** | ||
* Test that with CodeChecker configured, a confirmation message is displayed. | ||
*/ | ||
@Test | ||
public void testCodeCheckerFound() { | ||
Path ccDir = Utils.prepareCodeChecker(); | ||
|
||
SWTBotText text = bot.textWithLabel("CodeChecker package root directory"); | ||
text.setText(ccDir.toString()); | ||
text.setFocus(); | ||
bot.textWithLabel("Python virtualenv root directory (optional)").setFocus(); | ||
|
||
bot.sleep(SHORT_WAIT_TIME); | ||
|
||
SWTBotCLabel label = null; | ||
try { | ||
label = bot.clabel("CodeChecker package directory is valid"); | ||
} catch (WidgetNotFoundException e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
assertThat("There was no valid CodeChecker message displayed", label, is(IsNull.notNullValue())); | ||
|
||
preferencesShell.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.