Skip to content

things-kit/things-kit-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Things-Kit Testing

Testing Utilities for Things-Kit

Testing utilities to simplify integration testing of Things-Kit applications.

Installation

go get github.com/things-kit/things-kit-testing

Features

  • Test-friendly logger implementation
  • Fx application testing helpers
  • Integration test utilities

Quick Start

package myservice_test

import (
    "testing"
    "github.com/things-kit/things-kit-testing"
    "go.uber.org/fx"
)

func TestMyService(t *testing.T) {
    app := testing.NewTestApp(t,
        viperconfig.Module,
        logging.Module,
        fx.Provide(NewMyService),
        fx.Invoke(func(svc *MyService) {
            // Test your service
            result := svc.DoSomething()
            if result != expected {
                t.Errorf("expected %v, got %v", expected, result)
            }
        }),
    )
    
    app.RequireStart()
    app.RequireStop()
}

Test Logger

The testing module provides a test-friendly logger:

func TestWithLogging(t *testing.T) {
    logger := testing.NewTestLogger(t)
    
    logger.Info("test message", log.Field{Key: "key", Value: "value"})
    // Output goes to t.Log()
}

License

MIT License - see LICENSE file for details

About

Things-Kit Testing - Testing utilities and helpers for Things-Kit applications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages