https://github.com/henryssondaniel/teacup-java-example-junit
Example Teacup project with JUnit engine
https://github.com/henryssondaniel/teacup-java-example-junit
example http http-client http-request http-response http-server https junit junit5 protocol protocol-tester protocol-tests teacup test test-framework testing testing-framework testing-library testing-tool testing-tools
Last synced: 6 months ago
JSON representation
Example Teacup project with JUnit engine
- Host: GitHub
- URL: https://github.com/henryssondaniel/teacup-java-example-junit
- Owner: HenryssonDaniel
- License: mit
- Created: 2019-01-25T12:52:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-24T12:05:06.000Z (about 6 years ago)
- Last Synced: 2025-05-13T07:49:33.725Z (8 months ago)
- Topics: example, http, http-client, http-request, http-response, http-server, https, junit, junit5, protocol, protocol-tester, protocol-tests, teacup, test, test-framework, testing, testing-framework, testing-library, testing-tool, testing-tools
- Language: Java
- Homepage: https://henryssondaniel.github.io/teacup.github.io/
- Size: 120 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [User Guide](https://henryssondaniel.github.io/teacup.github.io/)
[](https://travis-ci.com/HenryssonDaniel/teacup-java-example-junit)
[](https://sonarcloud.io/dashboard?id=HenryssonDaniel_teacup-java-example-junit)
## What ##
This repository contains examples using the JUnit test engine.
## Why ##
It can be used as a reference to set up and write your first test case.
## How ##
### Add the dependencies ###
It has three dependencies:
1. Core (io.github.henryssondaniel.teacup:core)
1. JUnit test engine (io.github.henryssondaniel.teacup.engine:junit)
1. HTTP protocol (io.github.henryssondaniel.teacup.protocol:http)
### Add the test engine ###
1. Create a file named io.github.henryssondaniel.junit.platform.engine.TestEngine in src/main/resources/META-INF/services
1. Add the content io.github.henryssondaniel.teacup.engine.junit.TeacupTestEngine
1. 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
### Write your test (pseudocode) ###
Writing your test can be divided into three steps:
1. response = client.send(request) // send the request
2. node = responseBuilder.setStatusCode(statusCode).setVersion(version).build() // define the assertions
3. 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()