Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does sbt-scct support running test outside of scala project against instrumented classes? #62

Open
daiq opened this issue Aug 13, 2013 · 2 comments

Comments

@daiq
Copy link

daiq commented Aug 13, 2013

Looks I have to put test under scala project hierarchy tree. What if the test is not written in scala or java, neither does it use any Scala main testing framework and sit outside of the tree? What are the steps to follow in that case? Is there any step like to allow first, compile source code with scct-sbt, so that tests outside of scala project run against the instrumented source?

@daiq
Copy link
Author

daiq commented Aug 20, 2013

Update it myself. Tried for standard code, running test still required source code to be in the classpath even though instrumented classes are already there. Is this by design and required to get the report?

C:\ScalaExamples\standard_proj_819_test>scala -cp ".;scct_2.9.2-0.2-SNAPSHOT.jar" com.autodesk.my.MyTestObject
HELLO
scct: [default] Generating coverage report.
Exception in thread "Thread-0" java.io.FileNotFoundException: C:\ScalaExamples\standard_proj_819_test\MainObject.scala (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:120)
at scala.io.Source$.fromFile(Source.scala:91)
at scala.io.Source$.fromFile(Source.scala:76)
at scala.io.Source$.fromFile(Source.scala:81)
at reaktor.scct.report.SourceLoader.linesFor(SourceLoader.scala:8)
at reaktor.scct.report.SourceFileHtmlReporter$.report(SourceFileHtmlReporter.scala:11)
at reaktor.scct.report.HtmlReporter$$anonfun$sourceFileReports$2.apply(HtmlReporter.scala:92)
at reaktor.scct.report.HtmlReporter$$anonfun$sourceFileReports$2.apply(HtmlReporter.scala:91)
at scala.collection.immutable.TreeMap$$anonfun$foreach$1.apply(TreeMap.scala:160)
at scala.collection.immutable.RedBlack$NonEmpty.foreach(RedBlack.scala:164)
at scala.collection.immutable.TreeMap.foreach(TreeMap.scala:160)
at reaktor.scct.report.HtmlReporter.sourceFileReports(HtmlReporter.scala:91)
at reaktor.scct.report.HtmlReporter.report(HtmlReporter.scala:20)
at reaktor.scct.Coverage$.report(Coverage.scala:58)
at reaktor.scct.Coverage$$anon$1.run(Coverage.scala:67)

@daiq
Copy link
Author

daiq commented Aug 22, 2013

Continuing with the original question, I created a Play project and a junit test in scala which in turns calls a SoapUI test (test one GET api). I used scct:test to run the test and the soapui test runs and passed. However, the code coverage date shows 0% coverage which I observed from zero increase with other non-soapui junit test.

C:\ScalaExamples\PlayAppTestScala\todolist>sbt scct:test

C:\ScalaExamples\PlayAppTestScala\todolist>set SCRIPT_DIR=C:\Program Files (x86)\sbt\

C:\ScalaExamples\PlayAppTestScala\todolist>java -Xmx512M -XX:PermSize=128m -jar "C:\Program Files (x86)\sbt\sbt-launch.jar" scct:test
[info] Loading project definition from C:\ScalaExamples\PlayAppTestScala\todolist\project
[info] Set current project to todolis (in build file:/C:/ScalaExamples/PlayAppTestScala/todolist/)
[info] Compiling 1 Scala source to C:\ScalaExamples\PlayAppTestScala\todolist\target\scala-2.10\scct-test-classes...
[info] test.JunitTest
soapUI 4.5.2 TestCase Runner
18:02:45,407 WARN [SoapUI] Missing folder [C:\ScalaExamples\PlayAppTestScala\todolist.\ext] for external libraries
18:02:45,408 INFO [DefaultSoapUICore] Creating new settings at [C:\Users\daiq\soapui-settings.xml]
18:02:46,656 INFO [WsdlProject] Loaded project from [file:/C:/ScalaExamples/PlayAppTestScala/todolist/test/TestMyExampleSoapUI-soapui-project.xml]
18:02:47,474 INFO [SoapUITestCaseRunner] Running soapUI tests in project [TestMyExampleSoapUI]
18:02:47,475 INFO [SoapUITestCaseRunner] Running TestSuite [TestSuite 1], runType = SEQUENTIAL
18:02:47,485 INFO [SoapUITestCaseRunner] Running soapUI testcase [TestCase 1]
18:02:47,498 INFO [SoapUITestCaseRunner] running step [HTTP Test Request]
18:02:47,713 INFO [SoapUITestCaseRunner] Assertion [Valid HTTP Status Codes] has status VALID
18:02:47,714 INFO [SoapUITestCaseRunner] Finished running soapUI testcase [TestCase 1], time taken: 103ms, status: FINISHED
18:02:47,715 INFO [SoapUITestCaseRunner] TestSuite [TestSuite 1] finished with status [FINISHED] in 234ms
[info] + test.JunitTest.test
[info] + test.JunitTest.testSay
[info]
[info]
[info] Total for test test.JunitTest
[info] Finished in 2.815 seconds
[info] 2 tests, 0 failures, 0 errors
[info] Passed: : Total 2, Failed 0, Errors 0, Passed 2, Skipped 0
scct: [todolis] Generating coverage report.
[success] Total time: 8 s, completed Aug 22, 2013 6:02:48 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant