Giter Site home page Giter Site logo

contract-testing's Introduction

Hangman Server and Client (Contract Testing)

This repository contains a server (TypeScript+express) and client (TypeScript+Angular) for playing the word-guessing-game "hangman". The code is intentionally incomplete and has no tests (see below).

I created this repository to help a client practice contract testing using Pact, but you can potentially practice other skills using the code.

Incomplete and Untested

The code in this repository has no automated tests, and that's on purpose: there are some bugs in it.

And it is incomplete:

  • It allows users to guess letters again that they have already guessed
  • It does not recognize when a game was won or lost
  • It does not handle communication errors at all
  • It does not allow guessing the whole word to solve in one step
  • etc.

How You can Use the Code

I originally created the code to practice contract testing with a client.

Practice Contract Testing

If you want to try that, check out the branch pact-intro that contains the basic setup for Pact and two first tests.

On the client, run

npm run test

to run all tests, including the Pact tests. This will create the Pact file in the folder pacts. After that, run

npm run pact

on the server to run just the Pact tests. Both should pass after a fresh checkout of the branch.

Create more Pact tests to find the bug where the client and the server do not agree on the REST API (this bug can also be found by a code review, but that's not really the purpose here).

Bring Under Test

You could also use the code in this repository to practice adding characterization tests to existing code. Bring the code under test, accepting the current behavior as "correct"โ€”i.e., the current behavior is the "Golden Master".

Then check if all the tests make sense: If not, you might have found a bug.

Finish Test-Driven

After bringing the code under test, you can try to add the missing functionality in a test-driven way.

contract-testing's People

Contributors

dtanzer 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.