Ginkgo package testing

1.4k views Asked by At

I'm implementing test suite for brand new go app and decided to use ginkgo. The app has main function and several packages

.
|- main.go
|- types
|  |-- user.go
|  |-- post.go
|- server_pkg 
|  |-- users_controller.go
|  |-- posts_controller.go
|- worker_pkg
|  |-- users_worker.go
|  |-- posts_worker.go

I ran ginkgo bootstrap in each package folder and added test files using ginkgo generate. Now I'm able to run tests for each package separately i.e.
cd server_pkg; ginkgo

The question is that: how to configure my application to run all tests for main function and packages using single command?

I can chain commands like ginkgo; cd server_pkg; ginkgo ..., but it does not look like good solution.

2

There are 2 answers

0
ttomalak On BEST ANSWER

To run all test suits you should run this in command in your root catalog

ginkgo -r

Also is good practice as in normal test suits to run all test with race detector, also you could shuffle some test. You can run all this option by using

ginkgo -r --race --randomizeAllSpecs --randomizeSuites

0
Artem On

@ttomalak thank you! It's exactly what I wanted

$ ginkgo -r
enter image description here