# News from KotlinTest

**URL:** <https://discuss.kotlinlang.org/t/news-from-kotlintest/1797>\
**Category:** Uncategorized\
**Created:** [June 14, 2016, 8:21am UTC](https://discuss.kotlinlang.org/t/news-from-kotlintest/1797 "2016-06-14T08:21:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![medium](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/medium/32/10404_2.png) [@medium](https://discuss.kotlinlang.org/u/medium)\
**Post date:** [June 14, 2016, 8:21am UTC](https://discuss.kotlinlang.org/t/news-from-kotlintest/1797/1 "2016-06-14T08:21:13Z")

</div>

In the last weeks [KotlinTest](https://github.com/kotlintest/kotlintest) got some new and useful features:

## Testing for Exceptions

```auto
val exception = shouldThrow<IllegalAccessException> {
  // code in here that you expect to throw an IllegalAccessException
}
exception.message should start with "Something went wrong"

```

## Before and after each

```
override fun beforeEach() {
  println("Test starting")
}

override fun afterEach() {
  println("Test completed")
}

```

## Test configuration

Each test case can be followed by a call to the `config` function.

To execute a test ten times with two threads you would write:

```
class MyTests : ShouldSpec() {
  init {

    should("return the length of the string") {
      "sammy".length shouldBe 5
      "".length shouldBe 0
    }.config(invocations = 10, threads = 2)

  }
}

```

You can tag tests to be able run them selectively:

```
...
}.config(tags = listOf("database", "linux"))

```

Timeouts are configured like this:

```
...
}.config(timeout = 2, timeoutUnit = TimeUnit.SECONDS)

```

To ignore a test, you set `ignored` to true:

```
...
}.config(ignored = true)

```

## Future

Some more features like property based (and table driven) testing are on the roadmap.

---

<div class="post-metadata">

**Author:** ![neilg](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@neilg](https://discuss.kotlinlang.org/u/neilg)\
**Post date:** [June 14, 2016, 12:25pm UTC](https://discuss.kotlinlang.org/t/news-from-kotlintest/1797/2 "2016-06-14T12:25:20Z")

</div>

That looks great!

Table driven tests will be a good addition.
