Skip to content

Commit

Permalink
Make UI tests pass
Browse files Browse the repository at this point in the history
This commit uses Cucumber instead of JBehave to run BDD tests.
I made this choice because Cucumber seemed easier to integrate
within a Tycho build, especially because JBehave's JAR does not
include its dependencies.

As the two libraries usedvery similar API, changes made to the code are really minor.

/!\ 1 test still fail, likely because the away launch configurations are created has changed

Travis CI is able to run UI tests (#6).
  • Loading branch information
echebbi committed Aug 15, 2019
1 parent 90a828e commit 472a59c
Show file tree
Hide file tree
Showing 59 changed files with 1,397 additions and 876 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
language: java

jdk:
- openjdk8

# Prevent "mvn install" default step
install: true

env: DISPLAY=:99.0

addons:
apt:
packages:
- metacity

before_script:
- sh -e /etc/init.d/xvfb start
- metacity --sm-disable --replace 2> metacity.err &

script: mvn verify
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
* initializeDefaultPreferences()
*/
Expand All @@ -37,6 +37,7 @@ public void initializeDefaultPreferences() {
store.setDefault(DEFAULT_MUTATORS, "defaultMutators");
store.setDefault(TIMEOUT, DEFAULT_TIMEOUT);
store.setDefault(TIMEOUT_FACTOR, DEFAULT_TIMEOUT_FACTOR.toString());
store.setDefault(EXCLUDED_CLASSES, "*Test");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,20 @@ private Set<File> getSourceDirsFromProject(IJavaProject project) throws CoreExce
File projectRoot = new File(location);
for (IPackageFragmentRoot packageRoot : packageRoots) {
if (!packageRoot.isArchive()) {
File packagePath = removeProjectFromPackagePath(project, packageRoot.getPath());
sourceDirBuilder.add(new File(projectRoot, packagePath.toString()));
IPath packagePath = packageRoot.getPath();

boolean pathIsRelativeToWorkspace = ! (packagePath.isAbsolute() && packageRoot.isExternal());
if (pathIsRelativeToWorkspace) {
packagePath = removeProjectFromPackagePath(project, packageRoot.getPath());
sourceDirBuilder.add(new File(projectRoot, packagePath.toString()));
}
else {
// FIXME Commenting out this line leads UI tests to fail during Maven build
// because projects seem to have an additional source directory (which they
// do not have when tests are run by Eclipse IDE).
// It seems however that ignoring this case may cause issues in the future.
// sourceDirBuilder.add(packagePath.toFile());
}
}
}
return sourceDirBuilder.build();
Expand All @@ -59,8 +71,7 @@ private URI getProjectLocation(IProject project) throws CoreException {
return projLocation.toURI();
}

private File removeProjectFromPackagePath(IJavaProject javaProject, IPath packagePath) {
IPath newPath = packagePath.removeFirstSegments(1);
return newPath.toFile();
private IPath removeProjectFromPackagePath(IJavaProject javaProject, IPath packagePath) {
return packagePath.removeFirstSegments(1);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.pitest.pitclipse.ui.notify;

import org.eclipse.swt.widgets.Display;
import org.pitest.pitclipse.core.extension.point.ResultNotifier;
import org.pitest.pitclipse.runner.PitResults;
import org.pitest.pitclipse.ui.view.PitViewFinder;
Expand All @@ -8,7 +9,9 @@
public class PitResultsNotifier implements ResultNotifier<PitResults> {
@Override
public void handleResults(PitResults results) {
SummaryView view = PitViewFinder.INSTANCE.getSummaryView();
view.update(results.getHtmlResultFile());
Display.getDefault().asyncExec(() -> {
SummaryView view = PitViewFinder.INSTANCE.getSummaryView();
view.update(results.getHtmlResultFile());
});
}
}
16 changes: 15 additions & 1 deletion features/org.pitest.pitclipse.ui.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
provider-name="Pitest.org">

<description url="https://github.com/philglover/pitclipse">
UI integration of Pitest (PIT), a state of the art mutation systemfor the JVM.
UI integration of Pitest (PIT), a state of the art mutation system for the JVM.
Provides views and contextual actions to search the code for mutations and show vulnerabilities.
</description>

Expand Down Expand Up @@ -239,4 +239,18 @@ Provides views and contextual actions to search the code for mutations and show
version="0.0.0"
unpack="false"/>

<plugin
id="org.pitest.pitclipse.launch.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.pitest.pitclipse.preferences.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
14 changes: 14 additions & 0 deletions tests/io.cucumber/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="cucumber-core-4.3.0.jar"/>
<classpathentry exported="true" kind="lib" path="cucumber-expressions-6.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="cucumber-java-4.3.0.jar"/>
<classpathentry exported="true" kind="lib" path="cucumber-junit-4.3.0.jar"/>
<classpathentry exported="true" kind="lib" path="datatable-1.1.12.jar"/>
<classpathentry exported="true" kind="lib" path="datatable-dependencies-1.1.12.jar"/>
<classpathentry exported="true" kind="lib" path="gherkin-5.1.0.jar"/>
<classpathentry exported="true" kind="lib" path="tag-expressions-1.1.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions tests/io.cucumber/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>io.cucumber</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>
161 changes: 161 additions & 0 deletions tests/io.cucumber/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Cucumber
Bundle-SymbolicName: io.cucumber
Bundle-Version: 4.3.0
Bundle-ClassPath: cucumber-core-4.3.0.jar,
cucumber-expressions-6.2.2.jar,
cucumber-java-4.3.0.jar,
cucumber-junit-4.3.0.jar,
datatable-1.1.12.jar,
datatable-dependencies-1.1.12.jar,
gherkin-5.1.0.jar,
tag-expressions-1.1.1.jar
Export-Package: cucumber.api,
cucumber.api.cli,
cucumber.api.event,
cucumber.api.formatter,
cucumber.api.java,
cucumber.api.java.af,
cucumber.api.java.am,
cucumber.api.java.an,
cucumber.api.java.ar,
cucumber.api.java.ast,
cucumber.api.java.az,
cucumber.api.java.bg,
cucumber.api.java.bm,
cucumber.api.java.bs,
cucumber.api.java.ca,
cucumber.api.java.cs,
cucumber.api.java.cy_gb,
cucumber.api.java.da,
cucumber.api.java.de,
cucumber.api.java.el,
cucumber.api.java.en,
cucumber.api.java.en_au,
cucumber.api.java.en_lol,
cucumber.api.java.en_old,
cucumber.api.java.en_pirate,
cucumber.api.java.en_scouse,
cucumber.api.java.eo,
cucumber.api.java.es,
cucumber.api.java.et,
cucumber.api.java.fa,
cucumber.api.java.fi,
cucumber.api.java.fr,
cucumber.api.java.ga,
cucumber.api.java.gj,
cucumber.api.java.gl,
cucumber.api.java.he,
cucumber.api.java.hi,
cucumber.api.java.hr,
cucumber.api.java.ht,
cucumber.api.java.hu,
cucumber.api.java.id,
cucumber.api.java.is,
cucumber.api.java.it,
cucumber.api.java.ja,
cucumber.api.java.jv,
cucumber.api.java.ka,
cucumber.api.java.kn,
cucumber.api.java.ko,
cucumber.api.java.lt,
cucumber.api.java.lu,
cucumber.api.java.lv,
cucumber.api.java.mk_cyrl,
cucumber.api.java.mk_latn,
cucumber.api.java.mn,
cucumber.api.java.nl,
cucumber.api.java.no,
cucumber.api.java.pa,
cucumber.api.java.pl,
cucumber.api.java.pt,
cucumber.api.java.ro,
cucumber.api.java.ru,
cucumber.api.java.sk,
cucumber.api.java.sl,
cucumber.api.java.sr_cyrl,
cucumber.api.java.sr_latn,
cucumber.api.java.sv,
cucumber.api.java.ta,
cucumber.api.java.th,
cucumber.api.java.tl,
cucumber.api.java.tlh,
cucumber.api.java.tr,
cucumber.api.java.tt,
cucumber.api.java.uk,
cucumber.api.java.ur,
cucumber.api.java.uz,
cucumber.api.java.vi,
cucumber.api.java.zh_cn,
cucumber.api.java.zh_tw,
cucumber.api.java8,
cucumber.api.junit,
cucumber.runner,
cucumber.runtime,
cucumber.runtime.autocomplete,
cucumber.runtime.filter,
cucumber.runtime.formatter,
cucumber.runtime.io,
cucumber.runtime.java,
cucumber.runtime.junit,
cucumber.runtime.model,
cucumber.runtime.snippets,
cucumber.util,
gherkin,
gherkin.ast,
gherkin.cli,
gherkin.deps.com.google.gson,
gherkin.deps.com.google.gson.annotations,
gherkin.deps.com.google.gson.internal,
gherkin.deps.com.google.gson.internal.bind,
gherkin.deps.com.google.gson.reflect,
gherkin.deps.com.google.gson.stream,
gherkin.deps.net.iharder,
gherkin.events,
gherkin.pickles,
gherkin.stream,
io.cucumber.core.logging,
io.cucumber.core.model,
io.cucumber.core.options,
io.cucumber.cucumberexpressions,
io.cucumber.datatable,
io.cucumber.datatable.dependency.com.fasterxml.jackson.annotation,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.async,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.base,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.filter,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.format,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.io,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.json,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.json.async,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.sym,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.type,
io.cucumber.datatable.dependency.com.fasterxml.jackson.core.util,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.annotation,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.cfg,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.deser,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.deser.impl,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.deser.std,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.exc,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.ext,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.introspect,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.jsonFormatVisitors,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.jsonschema,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.jsontype,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.jsontype.impl,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.module,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.node,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.ser,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.ser.impl,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.ser.std,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.type,
io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.util,
io.cucumber.datatable.dependency.difflib,
io.cucumber.datatable.dependency.difflib.myers,
io.cucumber.stepexpression,
io.cucumber.tagexpressions
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: io.cucumber
Require-Bundle: org.junit;bundle-version="[4.12.0,5.0.0)"
9 changes: 9 additions & 0 deletions tests/io.cucumber/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bin.includes = META-INF/,\
cucumber-core-4.3.0.jar,\
cucumber-expressions-6.2.2.jar,\
cucumber-java-4.3.0.jar,\
cucumber-junit-4.3.0.jar,\
datatable-1.1.12.jar,\
datatable-dependencies-1.1.12.jar,\
gherkin-5.1.0.jar,\
tag-expressions-1.1.1.jar
Binary file added tests/io.cucumber/cucumber-core-4.3.0.jar
Binary file not shown.
Binary file added tests/io.cucumber/cucumber-expressions-6.2.2.jar
Binary file not shown.
Binary file added tests/io.cucumber/cucumber-java-4.3.0.jar
Binary file not shown.
Binary file added tests/io.cucumber/cucumber-junit-4.3.0.jar
Binary file not shown.
Binary file added tests/io.cucumber/datatable-1.1.12.jar
Binary file not shown.
Binary file not shown.
Binary file added tests/io.cucumber/gherkin-5.1.0.jar
Binary file not shown.
Binary file added tests/io.cucumber/tag-expressions-1.1.1.jar
Binary file not shown.
6 changes: 0 additions & 6 deletions tests/org.pitest.pitclipse.runner.tests/.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions tests/org.pitest.pitclipse.ui.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
Loading

0 comments on commit 472a59c

Please sign in to comment.