This repository contains examples using the JUnit test engine.
It can be used as a reference to set up and write your first test case.
It has three dependencies:
- Core (io.github.henryssondaniel.teacup:core)
- JUnit test engine (io.github.henryssondaniel.teacup.engine:junit)
- HTTP protocol (io.github.henryssondaniel.teacup.protocol:http)
- Create a file named io.github.henryssondaniel.junit.platform.engine.TestEngine in src/main/resources/META-INF/services
- Add the content io.github.henryssondaniel.teacup.engine.junit.TeacupTestEngine
- Add the engine to the build file, this is different depending on the build tool you are using.
The best thing is to check: https://junit.org/junit5/docs/current/user-guide/#running-tests-build
Writing your test can be divided into three steps:
- response = client.send(request) // send the request
- node = responseBuilder.setStatusCode(statusCode).setVersion(version).build() // define the assertions
- node.verify(response) // verify
All assertions can be chained and all setters take an assertion rather than a value.
This means that statusCode and version represents assertions as well. The code could look similar to this:
statusCode = integerBuilder.isLessThan(300).isGreaterThanOrEqualTo(200).build()
version = versionBuilder.isSameAs(Version.2).build()