Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Ginkgo panic when there is un handled error and skips next assertion #10

Closed
aneeshkp opened this issue Sep 9, 2020 · 2 comments
Closed

Comments

@aneeshkp
Copy link
Contributor

aneeshkp commented Sep 9, 2020

I think using Gomega assertions (Expect(...).To(...)) but do not use Ginkgo , causes this error.
This is hard to debug.

Panic is handled when using Ginkgo and Gomega together. The assertions are in It() or Specify() blocks and Ginkgo catches the panic()s and produces useful output.

https://onsi.github.io/ginkgo/#adding-specs-to-a-suite

@aneeshkp
Copy link
Contributor Author

aneeshkp commented Sep 9, 2020

I was able to catch those errors by adding the following functions into ginkgo tests, The panic is caused Since the go functions are not handling errors.

defer func() {
		// recover from panic if one occured. Set err to nil otherwise.
		if recover() != nil {
			err := errors.New("testNetworkConnectivity panic ")
			log.Error(err)
		}
	}()

@aneeshkp
Copy link
Contributor Author

This where it fails
Expected
<*json.SyntaxError | 0xc00000ebe0>: {
msg: "unexpected end of JSON input",
Offset: 0,
}
to be nil

  /go/src/github.com/redhat-nfvpe/test-network-function/test-network-function/generic/generic_cnf_tests.go:149

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant