Luciano
Luciano

Reputation: 8582

How to test SBT plugins

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.

Upvotes: 12

Views: 1994

Answers (2)

marios
marios

Reputation: 8996

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

Upvotes: 3

Eugene Yokota
Eugene Yokota

Reputation: 95624

(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.

Upvotes: 9

Related Questions