Giter Club home page Giter Club logo

henryssondaniel / teacup-java-example-junit Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 123 KB

Example Teacup project with JUnit engine

Home Page: https://henryssondaniel.github.io/teacup.github.io/

License: MIT License

Java 100.00%
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

teacup-java-example-junit's Introduction

Build Status Quality Gate Status

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)
  2. JUnit test engine (io.github.henryssondaniel.teacup.engine:junit)
  3. 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
  2. Add the content io.github.henryssondaniel.teacup.engine.junit.TeacupTestEngine
  3. 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()

teacup-java-example-junit's People

Contributors

henryssondaniel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.