An open API service indexing awesome lists of open source software.

https://github.com/corebreaker/texit

You could use os.Exit() in Go tests
https://github.com/corebreaker/texit

go golang testing testing-tools

Last synced: 11 months ago
JSON representation

You could use os.Exit() in Go tests

Awesome Lists containing this project

README

          

# texit
[![Report](https://goreportcard.com/badge/github.com/corebreaker/texit?style=plastic)](https://goreportcard.com/report/github.com/corebreaker/texit)
[![Build Status](https://img.shields.io/travis/com/corebreaker/texit/master.svg?style=plastic)](https://travis-ci.com/corebreaker/texit)
[![Coverage Status](https://img.shields.io/coveralls/github/corebreaker/texit/master.svg?style=plastic)](https://coveralls.io/github/corebreaker/texit)
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=plastic)](https://godoc.org/github.com/corebreaker/texit)
[![GitHub license](https://img.shields.io/github/license/corebreaker/texit.svg?color=blue&style=plastic)](https://github.com/corebreaker/texit/blob/master/LICENSE)
[![Release](https://img.shields.io/github/release/corebreaker/texit.svg?style=plastic)](https://github.com/corebreaker/texit/releases)

Yes, you can use os.Exit() in Go tests.

Inspired by https://talks.golang.org/2014/testing.slide#23

## Example in a testing function

```golang
import (
"os"

"github.com/corebreaker/texit"
)

func TestWithExitDirectCall(t *testing.T) {
stdout, stderr, status, err := DoTestWithExit(func() {
// Something to do

os.Exit(0)
})

// …
}
```