Skip to content
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

Improve punctuation and grammar #998

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/core-concepts.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Spek provides two built-in testing styles, but before proceeding to that - it is important to have a good
Spek provides two built-in testing styles, but before proceeding to that it is important to have a good
grasp on some core concepts.

## Structure
Tests are written using nested lambdas, each scope (level) can either be a `group` or a `test`.
Tests are written using nested lambdas. Each scope (level) can either be a `group` or a `test`.

```kotlin
object MyTest: Spek({
Expand All @@ -22,7 +22,7 @@ object MyTest: Spek({

Understanding the difference between each scope is crucial in writing correct tests.

- **Test** scope is where you place your assertions/checks (in JUnit dialect - this is your test method).
- **Test** scope is where you place your assertions/checks (in JUnit dialect this is your test method).
- **Group** scope is used to organize your tests. It can contain test scopes and other group scopes as well.
A very important thing to note is that group scopes will be **eagerly** executed during the *discovery phase*.
(more about this on the next section).
Expand Down Expand Up @@ -111,7 +111,7 @@ after root
```

## Scope values
As a best practice you typically want test values to be unique for each test this can be done by using a `lateinit` variable
As a best practice, you typically want test values to be unique for each test; this can be done by using a `lateinit` variable
and assigning it within a `beforeEachTest`.

```kotlin
Expand All @@ -128,7 +128,7 @@ To make it more concise, Spek provides `memoized` to do the same thing:
val calculator by memoized { Calculator() }
```

`memoized` should not be used to hold the result of an action, use a fixture instead.
`memoized` should not be used to hold the result of an action; use a fixture instead.

```kotlin
// BAD
Expand All @@ -147,15 +147,15 @@ beforeEachTest {
### Caching modes
You can pass in an optional parameter to `memoized` which controls how the values are cached.

- `CachingMode.TEST`: each test scope will receive a unique instance, this is the default.
- `CachingMode.TEST`: each test scope will receive a unique instance; this is the default.
- `CachingMode.EACH_GROUP`: each group scope will receive a unique instance.
- `CachingMode.SCOPE`: effectively a singleton.
- `CachingMode.INHERIT`: internal use only.

If you are using the [gherkin](gherkin.md) style note that the default caching mode is `CachingMode.EACH_GROUP`.
If you are using the [gherkin style](gherkin.md), note that the default caching mode is `CachingMode.EACH_GROUP`.

### Share common logic between tests
Often there is some code, which needs to be called repeatedly before and after tests.
Often there is some code which needs to be called repeatedly before and after tests.
To have code not duplicated through the code base, Spek allows sharing common logic through the use of Kotlin's extension functions.
Shared setup code can be implemented by declaring an extension function on the `Root` interface.
This function is accessible in every test class or object, which derives from `Spek`.
Expand Down