-
Notifications
You must be signed in to change notification settings - Fork 479
Update some docs still referencing Sputnik and JUnit runner and clarify situation of Jupiter extensions #2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ To learn more about unit testing, go to https://en.wikipedia.org/wiki/Unit_testi | |
|
|
||
| Let's start with a few definitions: Spock lets you write https://en.wikipedia.org/wiki/Specification_by_example[_specifications_] | ||
| that describe expected _features_ (properties, aspects) exhibited by a system of interest. The system of interest could be | ||
| anything between a single class and a whole application, and is also called the _system under specification or SUS_. | ||
| anything between a single class and a whole application, and is also called the _system under specification_ or _SUS_. | ||
| The description of a feature starts from a specific snapshot of the SUS and its collaborators; this snapshot is called the feature's _fixture_. | ||
|
|
||
| The following sections walk you through all building blocks of which a Spock specification may be composed. A typical | ||
|
|
@@ -48,9 +48,9 @@ A specification is represented as a Groovy class that extends from `spock.lang.S | |
| usually relates to the system or system operation described by the specification. For example, `CustomerSpec`, | ||
| `H264VideoPlayback`, and `ASpaceshipAttackedFromTwoSides` are all reasonable names for a specification. | ||
|
|
||
| Class `Specification` contains a number of useful methods for writing specifications. Furthermore it instructs JUnit to | ||
| run specification with `Sputnik`, Spock's JUnit runner. Thanks to Sputnik, Spock specifications can be run by most modern | ||
| Java IDEs and build tools. | ||
| Class `Specification` contains a number of useful methods for writing specifications. Furthermore it marks the specification | ||
| as `@Testable`, which instructs tools that only look at the source code - like typically IDEs and similar - that this | ||
| class is something that executes tests via a JUnit Platform engine. | ||
|
|
||
| == Fields | ||
|
|
||
|
|
@@ -841,20 +841,33 @@ block descriptions are enhanced diagnostic messages, and textual reports that ar | |
|
|
||
| As we have seen, Spock offers lots of functionality for writing specifications. However, there always comes a time | ||
| when something else is needed. Therefore, Spock provides an interception-based extension mechanism. Extensions are | ||
| activated by annotations called _directives_. Currently, Spock ships with the following directives: | ||
| activated by annotations called _directives_. Currently, Spock ships - among others - with the following directives: | ||
|
|
||
| [horizontal] | ||
| `@Timeout`:: Sets a timeout for execution of a feature or fixture method. | ||
|
|
||
| `@Ignore`:: Ignores any feature method carrying this annotation. | ||
|
|
||
| `@IgnoreRest`:: Any feature method carrying this annotation will be executed, all others will be ignored. Useful for quickly running just a single method. | ||
| `@IgnoreRest`:: Any feature method carrying this annotation will be executed, all others will be ignored. Useful for quickly running just a few features. | ||
|
|
||
| `@FailsWith`:: Expects a feature method to complete abruptly. `@FailsWith` has two use cases: First, to document known bugs that cannot | ||
| be resolved immediately. Second, to replace exception conditions in certain corner cases where the latter cannot be | ||
| used (like specifying the behavior of exception conditions). In all other cases, exception conditions are preferable. | ||
|
|
||
| Go to the <<extensions.adoc#extensions,Extensions>> chapter to learn how to implement your own directives and extensions. | ||
| Go to the <<extensions.adoc#extensions,Extensions>> chapter to learn how to implement your own directives and extensions, to learn where to find some of the 3rd party extensions, and to learn about all built-in extensions and directives. | ||
|
|
||
| [NOTE] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we include this twice?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feared you'd ask that. :-D I think it is important information to reduce the amount of issues reported in the style of "this JUnit extension does not work with Spock". Topic-wise I'd say it more belongs to the 3rd-party extensions section, as it is about 3rd-party "extensions", even though they are no Spock extensions but that is what users can wrongly assume easily and also in the Wiki article they might find a replacement or the bridging-extension. But I think if a user reads the docs at all, then it is more likely that they read the Spock Primer, at least to start with, so wanted to increase visibility of this admonition by having it there too. The |
||
| -- | ||
| JUnit Jupiter is a separate test engine also running on JUnit Platform and thus is a sibling of the Spock engine. | ||
| Extensions written for JUnit Jupiter do _not_ work in Spock specifications out of the box. | ||
| Often terms are mixed up and some extension says it is for JUnit 5+, actually meaning it is for JUnit Jupiter, as there are no generic JUnit Platform extensions. | ||
| If you want to use an extension written for JUnit Jupiter, you can check whether the project also provides a Spock extension, if not ask them to also provide a Spock extension, search for an alternative extension that supports Spock, or port the Jupiter extension to being a Spock extension yourself. | ||
|
|
||
| There is also at least one 3rd party extension that as of this writing provides a partly functioning integration of JUnit Jupiter extensions within Spock specifications. | ||
| This extension though is neither maintained, nor recommended, nor discouraged by the Spock maintainers. | ||
| It can eventually make some JUnit Jupiter extensions work within Spock specifications, but it is always preferable to instead use a native Spock extension. | ||
| Often porting a JUnit Jupiter extension to also support Spock is not a big effort, so you might strongly consider to request a port by the extension maintainer or contribute a port to its project. | ||
| -- | ||
|
|
||
| == Comparison to JUnit | ||
|
|
||
|
|
@@ -864,10 +877,10 @@ Although Spock uses a different terminology, many of its concepts and features a | |
| |Spock |JUnit | ||
|
|
||
| |Specification |Test class | ||
| |`setup()` |`@Before` | ||
| |`cleanup()` |`@After` | ||
| |`setupSpec()` |`@BeforeClass` | ||
| |`cleanupSpec()` |`@AfterClass` | ||
| |`setup()` |`@Before` / `@BeforeEach` | ||
| |`cleanup()` |`@After` / `@AfterEach` | ||
| |`setupSpec()` |`@BeforeClass` / `@BeforeAll` | ||
| |`cleanupSpec()` |`@AfterClass` / `@AfterAll` | ||
| |Feature |Test | ||
| |Feature method |Test method | ||
| |Data-driven feature |Theory | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.