Skip to content

Commit ca39f7e

Browse files
committed
Format README.md
1 parent 80c1e35 commit ca39f7e

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

README.md

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,50 @@
22

33
[ ![Download](https://api.bintray.com/packages/daniel-shuy/sbt-plugins/sbt-scripted-scalatest/images/download.svg) ](https://bintray.com/daniel-shuy/sbt-plugins/sbt-scripted-scalatest/_latestVersion)
44

5-
| Branch | Travis CI | Codacy |
6-
| ------- | --------- | ------ |
7-
| Master | [![Build Status](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin.svg?branch=master)](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/244276b4573e4ae899443fa79c34822b?branch=master)](https://www.codacy.com/app/daniel-shuy/scripted-scalatest-sbt-plugin?utm_source=github.com&utm_medium=referral&utm_content=daniel-shuy/scripted-scalatest-sbt-plugin&utm_campaign=Badge_Grade) |
8-
| Develop | [![Build Status](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin.svg?branch=develop)](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/244276b4573e4ae899443fa79c34822b?branch=develop)](https://www.codacy.com/app/daniel-shuy/scripted-scalatest-sbt-plugin?utm_source=github.com&utm_medium=referral&utm_content=daniel-shuy/scripted-scalatest-sbt-plugin&utm_campaign=Badge_Grade) |
5+
| Branch | Travis CI | Codacy |
6+
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
7+
| Master | [![Build Status](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin.svg?branch=master)](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/244276b4573e4ae899443fa79c34822b?branch=master)](https://www.codacy.com/app/daniel-shuy/scripted-scalatest-sbt-plugin?utm_source=github.com&utm_medium=referral&utm_content=daniel-shuy/scripted-scalatest-sbt-plugin&utm_campaign=Badge_Grade) |
8+
| Develop | [![Build Status](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin.svg?branch=develop)](https://travis-ci.org/daniel-shuy/scripted-scalatest-sbt-plugin) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/244276b4573e4ae899443fa79c34822b?branch=develop)](https://www.codacy.com/app/daniel-shuy/scripted-scalatest-sbt-plugin?utm_source=github.com&utm_medium=referral&utm_content=daniel-shuy/scripted-scalatest-sbt-plugin&utm_campaign=Badge_Grade) |
99

1010
| Plugin Version | SBT Version | ScalaTest Version |
1111
| -------------- | ------------- | ----------------- |
1212
| 1.x.x | 0.13.x, 1.x.x | 3.x.x |
1313

1414
A SBT plugin to use [ScalaTest](http://www.scalatest.org/) with scripted-plugin to test your SBT plugins
1515

16-
Traditionally, to test a SBT plugin, you had to create subprojects in `/sbt-test`, then in the subprojects, create SBT tasks to perform the testing, then specify the tasks to execute in a `test` file (see http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html).
16+
Traditionally, to test a SBT plugin, you had to create subprojects in `/sbt-test`, then in the subprojects, create SBT tasks to perform the testing, then specify the tasks to execute in a `test` file (see <http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html>).
1717

18-
This is fine when performing simple tests, but for complicated tests (see http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+6%3A+custom+assertion), this can get messy really quickly:
19-
- It sucks to not be able to write tests in a BDD style (except by using comments, which feels clunky).
20-
- Manually writing code to print the test results to the console for each subproject is a pain.
18+
This is fine when performing simple tests, but for complicated tests (see <http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+6%3A+custom+assertion>), this can get messy really quickly:
19+
20+
- It sucks to not be able to write tests in a BDD style (except by using comments, which feels clunky).
21+
- Manually writing code to print the test results to the console for each subproject is a pain.
2122

2223
This plugin leverages ScalaTest's powerful assertion system (to automatically print useful messages on assertion failure) and its expressive DSLs.
2324

2425
This plugin allows you to use any of ScalaTest's test [Suites](http://www.scalatest.org/user_guide/selecting_a_style), including [AsyncTestSuites](http://www.scalatest.org/user_guide/async_testing).
2526

2627
## Notes
27-
- Do not use ScalaTest's [ParallelTestExecution](http://doc.scalatest.org/3.0.0/index.html#org.scalatest.ParallelTestExecution) mixin with this plugin. `ScriptedScalaTestSuiteMixin` runs `sbt clean` before each test, which may cause weird side effects when run in parallel.
28-
- When executing SBT tasks in tests, use `Project.runTask(<task>, state.value)` instead of `<task>.value`. Calling `<task>.value` declares it as a dependency, which executes before the tests, not when the line is called.
29-
- When implementing [BeforeAndAfterEach](http://doc.scalatest.org/3.0.0/index.html#org.scalatest.BeforeAndAfterEach)'s `beforeEach`, make sure to invoke `super.beforeEach` afterwards:
28+
29+
- Do not use ScalaTest's [ParallelTestExecution](http://doc.scalatest.org/3.0.0/index.html#org.scalatest.ParallelTestExecution) mixin with this plugin. `ScriptedScalaTestSuiteMixin` runs `sbt clean` before each test, which may cause weird side effects when run in parallel.
30+
- When executing SBT tasks in tests, use `Project.runTask(<task>, state.value)` instead of `<task>.value`. Calling `<task>.value` declares it as a dependency, which executes before the tests, not when the line is called.
31+
- When implementing [BeforeAndAfterEach](http://doc.scalatest.org/3.0.0/index.html#org.scalatest.BeforeAndAfterEach)'s `beforeEach`, make sure to invoke `super.beforeEach` afterwards:
32+
3033
```scala
3134
override protected def beforeEach(): Unit = {
3235
// ...
3336
super.beforeEach() // To be stackable, must call super.beforeEach
3437
}
3538
```
36-
- This SBT plugin is now tested using itself!
39+
40+
- This SBT plugin is now tested using itself!
3741

3842
## Usage
3943

4044
### Step 1: Include the scripted-plugin in your build
4145

4246
Add the following to your main project's `project/scripted.sbt` (create file it if doesn't exist):
4347

44-
#### SBT 0.13 (http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+2%3A+scripted-plugin)
48+
#### SBT 0.13 (<http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+2%3A+scripted-plugin>)
4549

4650
```scala
4751
libraryDependencies += { "org.scala-sbt" % "scripted-plugin" % sbtVersion.value }
@@ -52,6 +56,7 @@ libraryDependencies += { "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
5256
```scala
5357
libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value }
5458
```
59+
5560
Note the %% operator.
5661

5762
#### SBT 1.2.x+
@@ -62,7 +67,7 @@ Not Required
6267

6368
Recommended settings by SBT:
6469

65-
#### SBT 0.13 (http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+2%3A+scripted-plugin)
70+
#### SBT 0.13 (<http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+2%3A+scripted-plugin>)
6671

6772
```scala
6873
// build.sbt
@@ -73,7 +78,7 @@ scriptedLaunchOpts := { scriptedLaunchOpts.value ++
7378
scriptedBufferLog := false
7479
```
7580

76-
If you are using [sbt-cross-building](https://github.com/jrudolph/sbt-cross-building) (SBT < 0.13.6), don't add scripted-plugin to `project/scripted.sbt`, and replace `ScriptedPlugin.scriptedSettings` in `build.sbt` with `CrossBuilding.scriptedSettings`.
81+
If you are using [sbt-cross-building](https://github.com/jrudolph/sbt-cross-building) (SBT &lt; 0.13.6), don't add scripted-plugin to `project/scripted.sbt`, and replace `ScriptedPlugin.scriptedSettings` in `build.sbt` with `CrossBuilding.scriptedSettings`.
7782

7883
#### SBT 1.0.x-1.1.x
7984

@@ -89,7 +94,7 @@ lazy val root = (project in file("."))
8994
)
9095
```
9196

92-
#### SBT 1.2.x+ (http://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html#step+2%3A+scripted-plugin)
97+
#### SBT 1.2.x+ (<http://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html#step+2%3A+scripted-plugin>)
9398

9499
```scala
95100
// build.sbt
@@ -110,32 +115,35 @@ Create the test subproject in `sbt-test/<test-group>/<test-name>`.
110115

111116
Include your plugin in the build.
112117

113-
See http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+3%3A+src%2Fsbt-test for an example.
118+
See <http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+3%3A+src%2Fsbt-test> for an example.
114119

115120
### Step 4: Include sbt-scripted-scalatest in your build
116121

117122
Add the following to your `sbt-test/<test-group>/<test-name>/project/plugins.sbt`:
123+
118124
```scala
119125
addSbtPlugin("com.github.daniel-shuy" % "sbt-scripted-scalatest" % "1.1.1")
120126
```
121127

122128
Override the `scalatest` dependency version with the version of ScalaTest you wish to use:
129+
123130
```scala
124131
addSbtPlugin("com.github.daniel-shuy" % "sbt-scripted-scalatest" % "1.1.1")
125132
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5"
126133
```
127134

128135
### Step 5: Configure `test` script
129136

130-
Put __only__ the following in the `sbt-test/<test-group>/<test-name>/test` script file:
137+
Put **only** the following in the `sbt-test/<test-group>/<test-name>/test` script file:
131138

132139
`> scriptedScalatest`
133140

134141
### Step 6: Configure project settings for the plugin
135142

136143
In `sbt-test/<test-group>/<test-name>/build.sbt`, create a new ScalaTest Suite/Spec, mixin `ScriptedScalaTestSuiteMixin` and pass it into `scriptedScalaTestSpec`. When mixing in `ScriptedScalaTestSuiteMixin`, implement `sbtState` as `state.value`.
137144

138-
Using SBT's Example in http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+6%3A+custom+assertion:
145+
Using SBT's Example in <http://www.scala-sbt.org/0.13/docs/Testing-sbt-plugins.html#step+6%3A+custom+assertion>:
146+
139147
```scala
140148
import com.github.daniel.shuy.sbt.scripted.scalatest.ScriptedScalaTestSuiteMixin
141149
import org.scalatest.Assertions._
@@ -176,15 +184,15 @@ Eg. Run `sbt scripted` on the main project to execute all tests.
176184

177185
| Setting | Type | Description |
178186
| -------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
179-
| scriptedScalaTestSpec | Option[Suite with ScriptedScalaTestSuiteMixin] | __Required__. The ScalaTest Suite/Spec. If not configured (defaults to `None`), no tests will be executed. |
180-
| scriptedScalaTestDurations | Boolean | __Optional__. If `true`, displays durations of tests. Defaults to `true`. |
181-
| scriptedScalaTestStacks | NoStacks / ShortStacks / FullStacks | __Optional__. The length of stack traces to display for failed tests. `NoStacks` will not display any stack traces. `ShortStacks` displays short stack traces. `FullStacks` displays full stack traces. Defaults to `NoStacks`. |
182-
| scriptedScalaTestStats | Boolean | __Optional__. If `true`, displays various statistics of tests. Defaults to `true`. |
187+
| scriptedScalaTestSpec | Option[Suite with ScriptedScalaTestSuiteMixin] | **Required**. The ScalaTest Suite/Spec. If not configured (defaults to `None`), no tests will be executed. |
188+
| scriptedScalaTestDurations | Boolean | **Optional**. If `true`, displays durations of tests. Defaults to `true`. |
189+
| scriptedScalaTestStacks | NoStacks / ShortStacks / FullStacks | **Optional**. The length of stack traces to display for failed tests. `NoStacks` will not display any stack traces. `ShortStacks` displays short stack traces. `FullStacks` displays full stack traces. Defaults to `NoStacks`. |
190+
| scriptedScalaTestStats | Boolean | **Optional**. If `true`, displays various statistics of tests. Defaults to `true`. |
183191

184192
## Tasks
185193

186-
| Task | Description |
187-
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194+
| Task | Description |
195+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
188196
| scriptedScalatest | Executes all test configured in `scriptedScalaTestSpec`. This task must be [configured for scripted-plugin to run in the `test` script file](#step-5-configure-test-script). |
189197

190198
## Licence
@@ -193,6 +201,6 @@ Copyright 2017, 2018, 2019 Daniel Shuy
193201

194202
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
195203

196-
http://www.apache.org/licenses/LICENSE-2.0
204+
<http://www.apache.org/licenses/LICENSE-2.0>
197205

198206
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

0 commit comments

Comments
 (0)