Giter Site home page Giter Site logo

btc-indexer's Introduction

Write Unit Tests

We have two business components service.Indexer & sync.syncClient that compose of some supported interfaces. The interfaces are defined as subscriber.Subscriber, store.Manager, blockchain.Client. Each interface has an individual functionality that to get more details, please take a look as them.

To be easy to write thoroughly Unit Test for the both important components, we use mixes of some libraries & tools as below:

testify testing suite

Intensively use mock package to mock real objects. Package mock provides a system by which it is possible to mock your objects and verify calls are happening as expected.

You can use the mockery tool to autogenerate the mock code against an interface as well, making using mocks much quicker.

mockery mock generation tool

Installation

go get github.com/vektra/mockery/.../, then $GOPATH/bin/mockery

Most used flags

Name

The -name option takes either the name or matching regular expression of interface to generate mock(s) for.

All

It's common for a big package to have a lot of interfaces, so mockery provides -all. This option will tell mockery to scan all files under the directory named by -dir ("." by default) and generates mocks for any interfaces it finds. This option implies -recursive=true.

Output

mockery always generates files with the package mocks to keep things clean and simple. You can control which mocks directory is used by using -output, which defaults to ./mocks.

ginkgo A Go BDD Testing Framework

gomega Ginkgo's Preferred Matcher Library

  • A matcher/assertion library. It is best paired with the Ginkgo BDD test framework, but can be adapted for use in other contexts too.

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.