Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run a single test in a suite?

Tags:

go

testify

I have setup a test suite for my struct (https://github.com/stretchr/testify#suite-package). Before I was able to run a single test by specifying just a pattern:

go test -v ./services/gateways/... -run mytest

This approach doesn't work after conversion. Bad luck or is there a way?

like image 815
Schultz9999 Avatar asked Nov 05 '16 01:11

Schultz9999


People also ask

How do you run only one describe jest?

Press p , and then type a filename. Then you can use describe. only and it. only which will skip all other tests from the filtered, tested file.

How do you run a single test case in Jasmine?

You can use fit() or fdescribe() instead of it() and describe() to achieve what is known as focussed test cases. describe("test spec", function() { it("test case 1", function() { }); fit("test case 2", function() { }); }); In the above example, only test case 2 would get executed.

How do I run a specific test in Golang?

Go provides the go test command for running the unit tests in a project. Running this command will ordinarily run the whole test suite, but you can limit it to only a specific file or test. If you run go test , it will run both the TestFactorial and TestSquare functions.


1 Answers

You can run single methods by specifying the -testify.m argument.

to run this suite method the command is:

go test -v github.com/vektra/mockery/mockery -run ^TestGeneratorSuite$ -testify.m TestGenerator

like image 69
Andy McCall Avatar answered Oct 17 '22 06:10

Andy McCall