Kotest
Script error: No such module "Draft topics".
Script error: No such module "AfC topic".
Developer(s) | Stephen Samuel, Leonardo Colman, Emil Kantis, Ashish Joy and others |
---|---|
Stable release | 5.6.2
/ May 10, 2023[1] |
Written in | Kotlin |
Engine | |
Operating system | Cross-platform |
Type | Unit testing tool |
License | Apache License 2.0[2] |
Website | kotest |
Search Kotest on Amazon.
Kotest is a unit testing framework for the Kotlin Programming Language, heavily inspired by Junit, ScalaTest, Cucumber and others.
Test Styles[edit]
Kotest features many test styles, most inspired by previous technology and practices, such as ScalaTest, JavaScript, RSpec, Cucumber and JUnit
FunSpec[edit]
Inspired by ScalaTest
class MyTests : FunSpec({
test("String length should return the length of the string") {
"sammy".length shouldBe 5
"".length shouldBe 0
}
})
DescribeSpec[edit]
Inspired by JavaScript and RSpec
class MyTests : DescribeSpec({
describe("score") {
it("start as zero") {
// test here
}
describe("with a strike") {
it("adds ten") {
// test here
}
it("carries strike to the next frame") {
// test here
}
}
describe("for the opposite team") {
it("Should negate one score") {
// test here
}
}
}
})
BehaviorSpec[edit]
Inspired by Behavior Driven Development
class MyTests : BehaviorSpec({
given("a broomstick") {
`when`("I sit on it") {
then("I should be able to fly") {
// test code
}
}
`when`("I throw it away") {
then("it should come back") {
// test code
}
}
}
})
FreeSpec[edit]
Inspired by ScalaTest
class MyTests : FreeSpec({
"String.length" - {
"should return the length of the string" {
"sammy".length shouldBe 5
"".length shouldBe 0
}
}
"containers can be nested as deep as you want" - {
"and so we nest another container" - {
"yet another container" - {
"finally a real test" {
1 + 1 shouldBe 2
}
}
}
}
})
WordSpec[edit]
Inspired by ScalaTest
class MyTests : WordSpec({
"String.length" should {
"return the length of the string" {
"sammy".length shouldBe 5
"".length shouldBe 0
}
}
})
FeatureSpec[edit]
Inspired by Cucumber
class MyTests : FeatureSpec({
feature("the can of coke") {
scenario("should be fizzy when I shake it") {
// test here
}
scenario("and should be tasty") {
// test here
}
}
})
AnnotationSpec[edit]
Inspired by JUnit
class AnnotationSpecExample : AnnotationSpec() {
@BeforeEach
fun beforeTest() {
println("Before each test")
}
@Test
fun test1() {
1 shouldBe 1
}
@Test
fun test2() {
3 shouldBe 3
}
}
See Also[edit]
Some use of "" in your query was not closed by a matching "".Some use of "" in your query was not closed by a matching "".
History[edit]
KotlinTest[edit]
Up to version 4.0 Kotest was called KotlinTest. In February 2019 a rebrand was discussed[3], being completed and released in March 2020.
-
KotlinTest logo from 2018[4]
References[edit]
- ↑ "Kotest Releases". github.com. Retrieved 2023-05-14.
- ↑ "Kotest License". github.com. 21 March 2016. Retrieved 2023-05-14.
- ↑ "Kotlintest Migration to Kotest issue". GitHub. 2019-02-15. Retrieved 2023-05-18.
- ↑ "Commit from 2018 replacing logo". GitHub. 2018-04-07. Retrieved 2023-05-18.
External links[edit]
This article "Kotest" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Kotest. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.