Giter Site home page Giter Site logo

junit-tests's Introduction

junit-tests

This project is intended to teach beginners working with unit tests using , junit5 and mockito.

Project Structure

Example Code is found in src/main/java, the associated tests can be found in src/test/java, dependencies are declared in build.gradle. If you use IntelliJ&rt;, a simple import from gradle should suffice, for eclipse a

./gradlew eclipse

is suggested.

Free Use

This repository may be used freely, providing that changes are not comitted on the master branch. To clone it from the command line, use:

git clone https://github.com/maegges65/junit-tests

Description

For each example, there is a separate package in both the main and the test folder.

demo

This has a simple class with a method whose logic depends solely on the method's parameters. The test class demonstrates how to cover the complete code.

demo2

A hypothetical example of a servo system with actors and sensors, where the latter are described as interfaces.

The test class demonstrates the use of mocks and verification of method calls.

demo3

Similar to demo2, but now actor and sensor are (stupid) concrete classes.

The test class demonstrates the use of spies.

demo4

Based on demo3, but this time a factory is used to create actor and sensor.

The test class demonstrates the use of the factory to avoid spies.

demo5

Based on demo4, but this time with a try {...} finally {...} block.

The test class demonstrate how to test behaviour for exceptions.

demo6

Based on demo3, but uses Mockito.mockConstruction() to mock constructors and verify method calls.

demo7

A simple example to demonstrate the the use of inorder verification.

robot

A simple example of a hyptothetical robot that moves along a rectangular spiral outwards. Look at the branch refactoring to see how this setup can be used for reactoring.

junit-tests's People

Contributors

maegges65 avatar

Watchers

James Cloos 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.