Giter Club home page Giter Club logo

Comments (4)

l3pp4rd avatar l3pp4rd commented on May 25, 2024 1

thanks for getting back with the answer reference, might be useful for someone else. If there would be a failure in package while running go test . then you would get detailed error, see bellow.

2017-03-23-144356

from godog.

l3pp4rd avatar l3pp4rd commented on May 25, 2024

Hi, depends on what exactly are you seeing, for example godog itself has a test suite integrated in TestMain with a progress format. So when you run it:

2017-03-21-130539

Note, you do not see the exact scenarios printed since it is a progress format. If you change it to pretty then you will get all details.

func TestMain(m *testing.M) {
	status := RunWithOptions("godog", func(s *Suite) {
		SuiteContext(s)
	}, Options{
		Format:      "pretty",
		Paths:       []string{"features/load.feature:22"}, // only one scenario for this example
	})

	if st := m.Run(); st > status {
		status = st
	}
	os.Exit(status)
}

2017-03-21-131103

That is the intended behavior. If you are seeing different things then give me more context about your environment..

Additionally, you can leverage -v option which go test is using and change the formatter based on that:

func TestMain(m *testing.M) {
	format := "progress"
	for _, arg := range os.Args[1:] {
		if arg == "-test.v=true" { // go test transforms -v option
			format = "pretty"
			break
		}
	}
	status := RunWithOptions("godog", func(s *Suite) {
		SuiteContext(s)
	}, Options{
		Format: format,
		Paths:  []string{"features/load.feature:22"},
	})

	if st := m.Run(); st > status {
		status = st
	}
	os.Exit(status)
}

And then instead of progress if -v option is used, you would get pretty printed features and detailed go test command output.

2017-03-21-132042

from godog.

valentin-krasontovitsch avatar valentin-krasontovitsch commented on May 25, 2024

Thanks for the prompt feedback, very helpful!
Indeed my setup was using the format progress, and I'm getting all the desired output when using pretty.

I also just noticed that I was a bit imprecise:

I'm actually using go test $(glide novendor) to run the test suite without running tests that might be included in vendored packages in the subfolder vendor/. In my case, the project is very simple, so glide novendor just returns . - and running go test . gives me just

ok      gitlab.knf.local/ngs/gpp        0.015s [no tests to run]

The no tests to run is due to the fact that I only have features, and just have a TestMain that runs those features. But even when I add a dummy test, I still have the same output behavior: Just one line when I call go test .

Running go test gives me all the desired output. Running go test -v . also solves the problem, i.e. I get all the output I need without running tests I don't want to run.

Was just wondering if anybody had an explanation for the difference in output behavior of go test when called with a directory, and when called on its own.

As this is actually a question about go test, I'm gonna go ahead and close the issue.

from godog.

valentin-krasontovitsch avatar valentin-krasontovitsch commented on May 25, 2024

Turns out that this is normal behavior - go test . tests the package found in . and testing packages prints out a summary for each package, which in the case of one package results in a one-liner... got this answer on Stackoverflow.

from godog.

Related Issues (20)

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.