Skip to content

Commit

Permalink
enhancement to run scalatest test with ScalaRunner
Browse files Browse the repository at this point in the history
currently the scalatest launcher uses standard java vm runner
to run or debug tests. It works fine with a java expression
evaluator but with the Scala IDE 4.1.0 there is available the
Scala Expression Evaluator which requires a Scala Debugger.
This enhancement adds a new scala launcher. From now it is
possible to choose appropriate launcher:
 - an old java one especially for java projects where tests are written
   with scalatest. Then debugging and evaluation can be done with a java
   evaluator
 - a new scala one for scala projects (can be used for java projects as
   well but is not documented).
You can stop in breakpoint during a test execution and evaluate
arbitrary expression.

This PR must be taken with scala-ide PR #955

Fix #1002447
  • Loading branch information
wpopielarski committed May 26, 2015
1 parent a29ebef commit f17d0ef
Show file tree
Hide file tree
Showing 46 changed files with 1,028 additions and 499 deletions.
3 changes: 2 additions & 1 deletion org.scala-ide.sdt.scalatest.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.scala-lang.scala-library,
org.eclipse.equinox.weaving.aspectj,
org.junit,
org.scala-ide.sdt.core
org.scala-ide.sdt.core,
org.scala-ide.sdt.debug
Import-Package: org.scalaide.core.testsetup,
org.aspectj.weaver.loadtime.definition
Bundle-ClassPath: .,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class ScalaTestLaunchTest {

import ScalaTestProject._

private def launch(launchName: String) {
private def launch(launchName: String, mode: String = ILaunchManager.RUN_MODE) {
val launchConfig = DebugPlugin.getDefault.getLaunchManager.getLaunchConfiguration(file(launchName + ".launch"))
launchConfig.launch(ILaunchManager.RUN_MODE, null)
launchConfig.launch(mode, null)
}

@Test
Expand Down Expand Up @@ -126,6 +126,146 @@ class ScalaTestLaunchTest {
launch("com.test.TestingFunSuite-'test2'")
}

@Test
def testLaunchComTestPackageWithScalaRunner() {
launch("com.test.scalarunner")
}

@Test
def testLaunchComTestPackageWithScalaDebugger() {
launch("com.test.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchSingleSpecFileWithScalaRunner() {
launch("SingleSpec.scala.scalarunner")
}

@Test
def testLaunchSingleSpecFileWithScalaDebugger() {
launch("SingleSpec.scala.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchMultiSpecFileWithScalaRunner() {
launch("MultiSpec.scala.scalarunner")
}

@Test
def testLaunchMultiSpecFileWithScalaDebugger() {
launch("MultiSpec.scala.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchSingleSpecWithScalaRunner() {
launch("SingleSpec.scalarunner")
}

@Test
def testLaunchSingleSpecWithScalaDebugger() {
launch("SingleSpec.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchStackSpec2WithScalaRunner() {
launch("StackSpec2.scalarunner")
}

@Test
def testLaunchStackSpec2WithScalaDebugger() {
launch("StackSpec2.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchTestingFreeSpecWithScalaRunner() {
launch("TestingFreeSpec.scalarunner")
}

@Test
def testLaunchTestingFreeSpecWithScalaDebugger() {
launch("TestingFreeSpec.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchTestingFunSuiteWithScalaRunner() {
launch("TestingFunSuite.scalarunner")
}

@Test
def testLaunchTestingFunSuiteWithScalaDebugger() {
launch("TestingFunSuite.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchConfigAStackshouldtastelikepeanutbutterWithScalaRunner() {
launch("AStackshouldtastelikepeanutbutter.scalarunner")
}

@Test
def testLaunchConfigAStackshouldtastelikepeanutbutterWithScalaDebugger() {
launch("AStackshouldtastelikepeanutbutter.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchConfigAStackwhenemptyshouldcomplainonpopWithScalaRunner() {
launch("AStackwhenemptyshouldcomplainonpop.scalarunner")
}

@Test
def testLaunchConfigAStackwhenemptyshouldcomplainonpopWithScalaDebugger() {
launch("AStackwhenemptyshouldcomplainonpop.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchConfigAStackwhenfullWithScalaRunner() {
launch("AStackwhenfull.scalarunner")
}

@Test
def testLaunchConfigAStackwhenfullWithScalaDebugger() {
launch("AStackwhenfull.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchConfigAStackwheneveritisemptycertainlyoughttocomplainonpeekWithScalaRunner() {
launch("AStackwheneveritisemptycertainlyoughttocomplainonpeek.scalarunner")
}

@Test
def testLaunchConfigAStackwheneveritisemptycertainlyoughttocomplainonpeekWithScalaDebugger() {
launch("AStackwheneveritisemptycertainlyoughttocomplainonpeek.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchConfigAStackwheneveritisemptyWithScalaRunner() {
launch("AStackwheneveritisempty.scalarunner")
}

@Test
def testLaunchConfigAStackwheneveritisemptyWithScalaDebugger() {
launch("AStackwheneveritisempty.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def testLaunchConfigAStackWithScalaRunner() {
launch("AStack.scalarunner")
}

@Test
def testLaunchConfigAStackWithScalaDebugger() {
launch("AStack.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Test
def `testLaunchConfigcom.test.TestingFunSuite-'test2'WithScalaRunner`() {
launch("com.test.TestingFunSuite-'test2'.scalarunner")
}

@Test
def `testLaunchConfigcom.test.TestingFunSuite-'test2'WithScalaDebugger`() {
launch("com.test.TestingFunSuite-'test2'.scalarunner", ILaunchManager.DEBUG_MODE)
}

@Ignore
def testLaunchExampleSpec1File() {
launch("ExampleSpec1.scala")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.SingleSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="scala.scalatest">
<stringAttribute key="SCALATEST_LAUNCH_INCLUDE_NESTED" value="false"/>
<setAttribute key="SCALATEST_LAUNCH_TESTS_NAME"/>
<stringAttribute key="SCALATEST_LAUNCH_TYPE" value="SUITE"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/scalatest/src/com/test/SingleSpec.scala"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.scalarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.scalarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.SingleSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.SingleSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="scala.scalatest">
<stringAttribute key="SCALATEST_LAUNCH_INCLUDE_NESTED" value="false"/>
<setAttribute key="SCALATEST_LAUNCH_TESTS_NAME">
<setEntry value="A Stack should taste like peanut butter"/>
</setAttribute>
<stringAttribute key="SCALATEST_LAUNCH_TYPE" value="SUITE"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/scalatest/src/com/test/SingleSpec.scala"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.scalarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.scalarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.SingleSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.StackSpec2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="scala.scalatest">
<stringAttribute key="SCALATEST_LAUNCH_INCLUDE_NESTED" value="false"/>
<setAttribute key="SCALATEST_LAUNCH_TESTS_NAME">
<setEntry value="A Stack when empty should complain on pop"/>
</setAttribute>
<stringAttribute key="SCALATEST_LAUNCH_TYPE" value="SUITE"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/scalatest/src/com/test/MultiSpec.scala"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.scalarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.scalarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.StackSpec2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.TestingFreeSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="scala.scalatest">
<stringAttribute key="SCALATEST_LAUNCH_INCLUDE_NESTED" value="false"/>
<setAttribute key="SCALATEST_LAUNCH_TESTS_NAME">
<setEntry value="A Stack whenever it is empty certainly ought to be empty"/>
<setEntry value="A Stack whenever it is empty certainly ought to complain on peek"/>
<setEntry value="A Stack whenever it is empty certainly ought to complain on pop"/>
</setAttribute>
<stringAttribute key="SCALATEST_LAUNCH_TYPE" value="SUITE"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/scalatest/src/com/test/MultiSpec.scala"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.scalarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.scalarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.TestingFreeSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.TestingFreeSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="scala.scalatest">
<stringAttribute key="SCALATEST_LAUNCH_INCLUDE_NESTED" value="false"/>
<setAttribute key="SCALATEST_LAUNCH_TESTS_NAME">
<setEntry value="A Stack whenever it is empty certainly ought to complain on peek"/>
</setAttribute>
<stringAttribute key="SCALATEST_LAUNCH_TYPE" value="SUITE"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/scalatest/src/com/test/MultiSpec.scala"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.scalarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.scalarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.TestingFreeSpec"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.StackSpec2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="scala.scalatest">
<stringAttribute key="SCALATEST_LAUNCH_INCLUDE_NESTED" value="false"/>
<setAttribute key="SCALATEST_LAUNCH_TESTS_NAME">
<setEntry value="A Stack when full should be full"/>
<setEntry value="A Stack when full should complain on push"/>
</setAttribute>
<stringAttribute key="SCALATEST_LAUNCH_TYPE" value="SUITE"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/scalatest/src/com/test/MultiSpec.scala"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.scalarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.scalarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.StackSpec2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.test.ExampleSpec1"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="/scalatest/src/com/test/ExampleSpec1.scala"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="scala.scalatest.javarunner"/>
<mapEntry key="[debug]" value="scala.scalatest.javarunner"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="/scalatest/src/com/test/MultiSpec.scala"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="scalatest"/>
</launchConfiguration>
Loading

0 comments on commit f17d0ef

Please sign in to comment.