Project
Scala
Priority
Minor
Type
Feature
Fix versions
No Fix versions
State
Submitted
Assignee
Alexander Podkhalyuzin
Subsystem
No subsystem
Affected versions
No Affected versions
Nika Fixed in build
No Fixed in build
  • Created by   James Strachan
    2 years ago (13 Jan 2010 19:56)
  • Updated by   Esko Luontola
    23 months ago (17 Jun 2010 04:01)
 
SCL-1724 SBT plugin so we can visualise test results in the IDEA test runner?
34
Issue is visible to: All Users
  The issue is visible to the selected user group only
Continuous Testing (i.e. re-running tests immediately after changing code) really helps improve the edit -> compile -> test loop. Currently doing build & rerunning the unit tests in Scala in IDEA on a typical maven project is pretty slow.

I tried using Infinitest as an IDEA plugin; which looks promising though it is a little slow, only kicks in when you select 'build' and the UI doesn't work too great when using ScalaTests.

I've blogged about how its really easy to use continuous testing with sbt (simple build tool); particularly if you already have a maven build...
http://macstrac.blogspot.com/2010/01/using-sbt-on-your-scala-maven-project.html

so its easy to use sbt in incremental mode; it incrementally compiles, loads & reruns tests really quickly. (Usually only a couple of seconds per change - much faster than just a build takes on IDEA on Scala projects). e.g. to rerun unit tests on my current project its about 20 seconds or so in IDEA using its make; in sbt its about 3 seconds

The only downside is when there are failures, there's no fast way to navigate them from IDEA. I basically want to see the usual unit test window in IDEA, which updates dynamically as sbt reruns tests; then any stack traces get shown in the IDEA UI so I can easily navigate to points in stack traces.

So I was wondering; what if there was some kind of sbt plugin for IDEA; where we can get sbt test runner to try connect to some network port or URI - or write files to some well known localtion which the sbt IDEA plugin could see, and it would just grab the tests run, their results and the console output and render the usual test runner window? i.e. so we can watch the results of sbt inside the IDEA UI and click/navigate to failed tests and stack traces?

Basically its another kind of test runner which actually doesn't do anything other than listen to what sbt it doing (and you run that separately in a shell - then you get smart completion & colour coding in the shell)? The other option is you run sbt from inside IDEA - though not sure the completion would all work etc? Either way - the main issue really is just grabbing the results of running tests from SBT so we can render them nicely to the IDEA UI so scala developer get super fast continuous testing feedback
Comments (10)
 
History
 
Linked Issues (?)
 
TeamCity Changes (0)
 
James Strachan
  James Strachan
13 Jan 2010 20:41
2 years ago
Incidentally you can run SBT 0.6.9 inside IDEA. To do this I created a new module in a project, using the sbt project/build directory for the source where the SBT configuration is - and add the sbt-launchar.jar as a dependency.

Then you can create an Application in IDEA where you add
  • main class: xsbt.boot.Boot
  • VM arguments: -Dsbt.log.noformat=true

(the last line turns off the colors from the terminal)

Then when running in continuous testing mode by entering the following into the shell "~ test" then you get test failure stack traces nicely formatted so you can click on the lines to get to the code.

You lose tab completion in the shell though.

The main issue is its not as easy to read/navigate the console output as it is the JUnit UI (particularly switching between different failures)
James Strachan
  James Strachan
13 Jan 2010 20:55
2 years ago
Just using sbt inside IDEA using the above mechanism, it'd be quite easy to parse the console output to detect tests being ran.

e.g. "== test-start ==" is the start of a test run and "== test-finish ==" indicates the end. Then within there, you just look for "[info] == nameOfClassBeingTested ==" to represent a test class being ran, then a test name working looks like

[info] Test Starting: someName
[info] Test Passed: someName

and a failure

info] Test Starting: someName
[error] Test Failed: someName
[error] Expected someError....

Then rather like the JUnit UI, we can capture the log and put it into a test class/method specific area so you can see the tests ran, the ones that failed and for failed tests zoom in on the console output etc
Barry Kaplan
  Barry Kaplan
15 Jan 2010 00:39
2 years ago
I guess I would rather see the scala plugin do whatever it is the sbt is doing to work incrementally.
Daniel Sobral
  Daniel Sobral
15 Jan 2010 00:47
2 years ago
Well, IDEA can improve what it has right now by using the new incremental compilation options available on Scala 2.8. To do what SBT does, however, would require it to run fsc with a plugin. That would speed up compilation, certainly, but it misses part of the point. An SBT "configuration" is a Scala program, which enables very complex settings. While speeding up compilation is a laudable goal in itself, it can never replace a complex tool such as SBT when such is needed.
James Strachan
  James Strachan
15 Jan 2010 12:53
2 years ago
Yeah - an ideal would be IDEA doing what SBT is doing; but I figured a simple tactical solution would be to just render the test results in IDEA
Ben Jackman
  Ben Jackman
03 Feb 2010 10:30
2 years ago
I added a post expanding you idea James to the sbt group, I agree with the tactical solution as I am blow-away by the features and power sbt, they go well beyond just fsc as they allow for all sorts of interesting behaviour. http://groups.google.com/group/simple-build-tool/browse_thread/thread/a0cdaccc76c2384a I think we could probably get something working quickly with a little hacking.
Ben Jackman
  Ben Jackman
03 Feb 2010 13:23
2 years ago
I found a way to get something that works pretty well it requires a simple patch of sbt, otherwise it works great, for running continuous compile / testing in intellij see the mailing list posting above for more details.
Alexander Podkhalyuzin
  Alexander Podkhalyuzin
14 Apr 2010 14:04
2 years ago
If sbt will have Notifier class like Specs, I'll create runner for sbt to parse tests output like for JUnit. It's better to have such notifier then to parse sbt output.
James Strachan
  James Strachan
14 Apr 2010 14:22
2 years ago
SBT has a TestsListener you can implement to be notified of tests running. I implemented it here on webbytest to make a HTML report of tests...

http://github.com/jstrachan/webbytest/blob/master/src/main/scala/webbytest/HtmlTestsListener.scala

this page describes how to add it to your sbt project....
http://github.com/jstrachan/webbytest

The only downside with this approach is you have to add the listener to your sbt project. I'm not sure if there's a way to add a listener dynamically without changing the project (e.g. specifying the IDEA listener as a command line argument to the sbt command).

Still it'd be an awesome first step, if there was an IDEA TestsListener folks could add to their projects - then we can figure out how to make that plugin an optional thing (so it can be specified as an environment setting or command line argument or something)
Related Changes
Type
ExceptionFeature
Assignee
Alexander Podkhalyuzin (alefas)Alexander Podkhalyuzin
Subsystem
<lost change>No subsystem
Esko Luontola
  Esko Luontola
17 Jun 2010 04:01
23 months ago
I have now released an SBT plugin for IntelliJ IDEA: http://plugins.intellij.net/plugin/?idea&id=5007

It can be used to compile the Scala projects and execute any other SBT commands from within IDEA.