Giter Site home page Giter Site logo

golang-clean-test-code-showcase's Introduction

golang-clean-test-code-showcase

A showcase, of how unit test can be written. No claim to be complete here.

Business requirement - for this demo purpose

This showcase/demo library has some acceptance criteria

  • as a developer I would like to extract meaningful information from a condensed firmware string literal
  • the information extraction must work on a single line string
  • the information extraction must work on multi-line strings, separated by newline (\n)
  • these fields must be available in the meaningful extracted information (struct)
    • FirmwareName,TargetName,TargetDetail,Version,ReleaseDateStr,GitHash,ReleaseTime

Example firmware String:
Betaflight / SPRACINGF3EVO (SPEV) 3.4.0 Apr 17 2018 / 14:00:13 (b2c247d34) MSP API: 1.39

Implementations

  1. Using native/vanilla GO language and library
  2. Using famous stretchr/testify library
  3. Using broken and outdated rdrdr/hamcrest library
  4. Using almost unknown corbym/gocrest library

What is / Why "HAMCREST"?

Hamcrest is a famous Java Library, that was developed to make unit tests in Java more readable and follow Clean Code principles

Cite from hamcrest.org ...
Matchers that can be combined to create flexible expressions of intent
Born in Java, Hamcrest now has implementations in a number of languages

golang-clean-test-code-showcase's People

Contributors

nitram509 avatar

Watchers

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