Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test SBT plugins

Tags:

sbt

Is there any tutorial for the scripted plugin? Or maybe a new way to test plugins. I've found a tutorial that seems to be a bit old.

If I have to resort to Scripted, some questions that come to my mind:

  1. Do I need to publish local my plugin before running scripted?
  2. Can I refer to the version located in version.sbt from my tests?

For the record, I'm also using the cross-build plugin, so if possible, the tests would need to cover both 0.12 and 0.13 versions.

like image 901
Luciano Avatar asked Sep 30 '13 19:09

Luciano


People also ask

Where can I find plugins sbt?

Plugins can be installed for all your projects at once by declaring them in $HOME/. sbt/1.0/plugins/ .

How do I run a Scala test?

Run Scala tests with coverageOpen your project. Open the test in question in the editor. icon and select the Run 'name' with Coverage option.

What are sbt plugins?

A plugin can define a sequence of sbt settings that are automatically added to all projects or that are explicitly declared for selected projects. For example, a plugin might add a proguard task and associated (overridable) settings. Finally, a plugin can define new commands (via the commands setting).


2 Answers

(Author of the linked testing sbt plugins here) There hasn't been major changes to scripted since I first wrote it, but I updated some of the details.

  1. To test the plugin end-to-end, publishing locally I think makes sense.
  2. See the updated post. You can pass version number as a property using scriptedLaunchOpts, and catch it with System.getProperty on the other side.
like image 145
Eugene Yokota Avatar answered Sep 23 '22 10:09

Eugene Yokota


Eugene's answer is still relevant, but now, Sbt Plugins Testing has a proper documentation page in the official sbt documnetation site:

http://www.scala-sbt.org/release/docs/Testing-sbt-plugins.html

like image 22
marios Avatar answered Sep 22 '22 10:09

marios