Skip to content

Commit

Permalink
Merge pull request #121 from LorenzoBettini/UI-test-refactoring
Browse files Browse the repository at this point in the history
UI test refactoring
  • Loading branch information
LorenzoBettini committed Jul 2, 2021
2 parents 599d23a + 535d778 commit b8de469
Show file tree
Hide file tree
Showing 46 changed files with 778 additions and 341 deletions.
6 changes: 6 additions & 0 deletions javamm.tests.report/pom.xml
Expand Up @@ -83,5 +83,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>javamm.swtbot.tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
8 changes: 8 additions & 0 deletions javamm.ui.tests.project/.classpath
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<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="output" path="bin"/>
</classpath>
34 changes: 34 additions & 0 deletions javamm.ui.tests.project/.project
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>javamm.ui.tests.project</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>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions javamm.ui.tests.project/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
12 changes: 12 additions & 0 deletions javamm.ui.tests.project/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
Manifest-Version: 1.0
Automatic-Module-Name: javamm.ui.tests.project
Bundle-ManifestVersion: 2
Bundle-Name: javamm.ui.tests.project
Bundle-Vendor: Lorenzo Bettini
Bundle-Version: 1.11.0.qualifier
Bundle-SymbolicName: javamm.ui.tests.project; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: javamm.runtime
Import-Package: org.apache.log4j,
org.apache.commons.logging
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
4 changes: 4 additions & 0 deletions javamm.ui.tests.project/build.properties
@@ -0,0 +1,4 @@
source.. = src/,\
./src-gen/
bin.includes = META-INF/,\
.
2 changes: 2 additions & 0 deletions javamm.ui.tests.project/src-gen/.gitignore
@@ -0,0 +1,2 @@
*.java
!*Test.java
Empty file.
10 changes: 10 additions & 0 deletions javamm.ui.tests.selfassessment.project.student/.classpath
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="src" path="src-gen"/>
<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="lib" path="solution"/>
<classpathentry kind="output" path="bin"/>
</classpath>
34 changes: 34 additions & 0 deletions javamm.ui.tests.selfassessment.project.student/.project
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>javamm.ui.tests.selfassessment.project.student</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>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Automatic-Module-Name: javamm.ui.tests.selfassessment.project.student
Bundle-ManifestVersion: 2
Bundle-Name: javamm.ui.tests.selfassessment.project.student
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: javamm.ui.tests.selfassessment.project.student; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: javamm.runtime,
org.junit
Import-Package: org.apache.log4j,
org.apache.commons.logging
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
@@ -0,0 +1,6 @@
source.. = src/,\
tests/,\
src-gen/
bin.includes = META-INF/,\
.
output.. = solution/
@@ -0,0 +1,2 @@
*
!.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions javamm.ui.tests.selfassessment.project.teacher/.classpath
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<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="output" path="bin"/>
</classpath>
40 changes: 40 additions & 0 deletions javamm.ui.tests.selfassessment.project.teacher/.project
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>javamm.ui.tests.selfassessment.project.teacher</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>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>javamm.selfassessment.builder.javammSelfAssessmentBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>javamm.selfassessment.builder.javammSelfAssessmentNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Automatic-Module-Name: javamm.ui.tests.selfassessment.project.teacher
Bundle-ManifestVersion: 2
Bundle-Name: javamm.ui.tests.selfassessment.project.teacher
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: javamm.ui.tests.selfassessment.project.teacher; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: javamm.runtime,
org.junit
Import-Package: org.apache.log4j,
org.apache.commons.logging
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
@@ -0,0 +1,4 @@
source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file.
20 changes: 16 additions & 4 deletions javamm.ui.tests/.classpath
@@ -1,9 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src-gen">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="xtend-gen">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<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="output" path="bin"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions javamm.ui.tests/META-INF/MANIFEST.MF
Expand Up @@ -12,6 +12,7 @@ Require-Bundle: javamm.ui,
org.eclipse.jdt.ui,
org.eclipse.pde.core;bundle-version="3.10.2",
org.eclipse.jdt.core,
org.eclipse.ui.ide,
javamm.selfassessment.builder,
org.eclipse.xtext.common.types.ui,
org.eclipse.xtext.testing,
Expand Down
@@ -1,22 +1,16 @@
package javamm.ui.tests

import com.google.inject.Inject
import javamm.tests.utils.ui.PDETargetPlatformUtils
import javamm.tests.utils.ui.PluginProjectHelper
import org.eclipse.jface.wizard.Wizard
import org.eclipse.jface.wizard.WizardDialog
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.ui.testing.AbstractWorkbenchTest
import org.junit.BeforeClass
import org.junit.runner.RunWith

@RunWith(typeof(XtextRunner))
@InjectWith(typeof(JavammUiInjectorProvider))
abstract class JavammAbstractWizardTest extends AbstractWorkbenchTest {

@Inject protected PluginProjectHelper projectHelper

/**
* Create the wizard dialog, open it and press Finish.
*/
Expand Down Expand Up @@ -53,9 +47,4 @@ abstract class JavammAbstractWizardTest extends AbstractWorkbenchTest {
return dialog.open();
}

@BeforeClass
def static void beforeClass() {
PDETargetPlatformUtils.setTargetPlatform();
}

}
Expand Up @@ -3,7 +3,7 @@ package javamm.ui.tests
import com.google.inject.Inject
import com.google.inject.Provider
import javamm.tests.utils.ui.JavammTestableNewFileWizard
import javamm.tests.utils.ui.JavammTestableNewProjectWizard
import javamm.tests.utils.ui.ProjectImportUtil
import org.eclipse.jface.viewers.StructuredSelection
import org.eclipse.ui.PlatformUI
import org.eclipse.xtext.testing.InjectWith
Expand All @@ -12,36 +12,50 @@ import org.junit.Test
import org.junit.runner.RunWith

import static org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil.*
import org.junit.Before
import org.eclipse.core.resources.IProject
import org.eclipse.core.runtime.Path
import javamm.tests.utils.ui.PluginProjectHelper

@RunWith(typeof(XtextRunner))
@InjectWith(typeof(JavammUiInjectorProvider))
class JavammNewFileWizardTest extends JavammAbstractWizardTest {

@Inject Provider<JavammTestableNewFileWizard> fileWizardProvider


val static TEST_PROJECT = "javamm.ui.tests.project"

var IProject project

@Before
def void importProject() {
project = ProjectImportUtil.importProject(TEST_PROJECT)
waitForBuild
}

@Test def void testJavammNewFileWizard() {
println("Creating project...")
val project = projectHelper.createJavaPluginProject
(JavammTestableNewProjectWizard.TEST_PROJECT, newArrayList("javamm.runtime")).project
val srcFolder = project.getFolder("src")
assertTrue(srcFolder.exists)
val wizard = fileWizardProvider.get
wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(srcFolder))
println("Using new file wizard...")
createAndFinishWizardDialog(wizard)
val file = srcFolder.getFile(JavammTestableNewFileWizard.TEST_FILE + ".javamm")
val filePath = new Path("src")
.append(TEST_PROJECT.replace(".", "/"))
.append(JavammTestableNewFileWizard.TEST_FILE + ".javamm")
val file = project.getFile(filePath)
assertTrue(file.exists())
println("Waiting for build...")
waitForBuild
projectHelper.assertNoErrors
PluginProjectHelper.assertNoErrors
println("Waiting for build...")
waitForBuild
val srcGenFolder = project.getFolder("src-gen/javamm")
assertTrue("src-gen/javamm does not exist", srcGenFolder.exists)
val genfile = srcGenFolder.getFile(JavammTestableNewFileWizard.TEST_FILE + ".java")
assertTrue(JavammTestableNewFileWizard.TEST_FILE + ".java does not exist" , genfile.exists())
projectHelper.assertNoErrors
assertTrue(JavammTestableNewFileWizard.TEST_FILE + ".java does not exist", genfile.exists())
PluginProjectHelper.assertNoErrors
println("No errors in project, OK!")
}

}
}

0 comments on commit b8de469

Please sign in to comment.