# Tutorial or examples for unit testing?

**URL:** <https://discuss.kotlinlang.org/t/tutorial-or-examples-for-unit-testing/1040>\
**Category:** Uncategorized\
**Created:** [November 5, 2012, 7:22pm UTC](https://discuss.kotlinlang.org/t/tutorial-or-examples-for-unit-testing/1040 "2012-11-05T19:22:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ianclarke](https://avatars.discourse-cdn.com/v4/letter/i/7bcc69/32.png) [@ianclarke](https://discuss.kotlinlang.org/u/ianclarke)\
**Post date:** [November 5, 2012, 7:22pm UTC](https://discuss.kotlinlang.org/t/tutorial-or-examples-for-unit-testing/1040/1 "2012-11-05T19:22:35Z")

</div>

Can anyone point me to a tutorial or easy-to-understand examples for how to create Kotlin unit tests?&nbsp;&nbsp;Note that I'm using Maven.

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [November 5, 2012, 9:26pm UTC](https://discuss.kotlinlang.org/t/tutorial-or-examples-for-unit-testing/1040/2 "2012-11-05T21:26:38Z")

</div>

JUnit 3: Just create a class that extens TestCase, everything else is also exactly like Java

JUnit 4: example here: [https://github.com/abreslav/introduction-to-kotlin/blob/master/kotlin-examples/src/\_07\_annotations/Tests.kt](https://github.com/abreslav/introduction-to-kotlin/blob/master/kotlin-examples/src/_07_annotations/Tests.kt)

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [November 5, 2012, 9:27pm UTC](https://discuss.kotlinlang.org/t/tutorial-or-examples-for-unit-testing/1040/3 "2012-11-05T21:27:44Z")

</div>

A Maven project with tests, written in Kotlin: [https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib](https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib)

---

<div class="post-metadata">

**Author:** ![jstrachan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jstrachan/32/1559_2.png) [@jstrachan](https://discuss.kotlinlang.org/u/jstrachan)\
**Post date:** [November 6, 2012, 9:47am UTC](https://discuss.kotlinlang.org/t/tutorial-or-examples-for-unit-testing/1040/4 "2012-11-06T09:47:18Z")

</div>

Also there's a few testing helper methods in the [kotlin.test.\*](http://jetbrains.github.com/kotlin/versions/snapshot/apidocs/kotlin/test/package-summary.html) package (which work with no other dependencies apart from kotlin stdlib or with JUnit if its on the classpath - we should be able to create a TestNG plugin too). e.g.

> failsWith\<SomeException\> { ... } todo { &nbsp;&nbsp;.... } expect(5) { ... }
