How do you print in a Go test using the "testing" package? -


I'm running a test in Go with a statement to print something (i.e. for the debugging of tests), But it is not printing anything.

  Funk testPrintSomething (t * testing.T.) {Fmt.Println ("Hi Hi"}}   

When I run a test on this file , This output is:

  OK, Command-line-Arguments 0.004s   

Actually the only way to print it, as far as I know , It is printed via t.Error (), such as:

  Funk testPrintSomethingAgain (t * testing.T.) {T.Error ("Say hi")}   

Which outputs to this:

  Say- Failure: Testing something (0.00 seconds) foo_test.go: 35: Say, A Fruit failed command-line arguments 0.003s gom: get out of position 1   

I've seen through Googled and manual but found nothing.

There is another way between the strokes and the two that are looking for you.

fmt.X print statement do work inside the tests, but you will find that their output is probably not on the screen where you find it , And therefore, why should you use the logging methods in the testing .

If in your case, you want to see the logs of those tests which are not unsuccessful, you have passed the ja exam to -v the flag of verbosity For v) provided. More information about the test flag can be found here:

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -