forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a scala specs2 example (pantsbuild#4516)
Adding a specs2 example, so it is more clear how it can be used. Also tested in an IntelliJ project, the tests run as expected as well in both IntelliJ JUnit runner and specs2 runner.
- Loading branch information
1 parent
7788817
commit 8b3395c
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
jar_library( | ||
name='specs2-junit_2.11', | ||
jars=[ | ||
jar(org='org.specs2', name='specs2-junit_2.11', rev='3.8.9'), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
junit_tests( | ||
dependencies=[ | ||
'3rdparty/jvm/org/specs2:specs2-junit_2.11', | ||
], | ||
) |
17 changes: 17 additions & 0 deletions
17
examples/tests/scala/org/pantsbuild/example/specs2/HelloWorldSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
package org.pantsbuild.example.specs2 | ||
|
||
import org.specs2.mutable.SpecificationWithJUnit | ||
|
||
class HelloWorldSpec extends SpecificationWithJUnit { | ||
|
||
"add three numbers" in { | ||
1 + 1 + 1 mustEqual 3 | ||
} | ||
|
||
"add 2 numbers" in { | ||
1 + 1 mustEqual 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Scala Specs2 Example | ||
|
||
Pants supports Scala Specs2. In order for it to work you have to extend the `SpecificationWithJUnit` class, because Pants uses JUnit's runner to run tests. | ||
|
||
You can run these tests with the command: | ||
|
||
`./pants test examples/tests/scala/org/pantsbuild/example/specs2` | ||
|
||
This target can also be imported in IntelliJ. If you choose to run it with IntelliJ Scala Runner, you can see a Specs2 run configuration generated under Run -> Edit Configurations. |