google / google/sbom-conformance

Improve tests

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3
Forks
4
PR merge metrics
No merged PRs in 30d

Description

The tests aren't in a great state. Here a list of issues
- There is a lot of indexing into slices ([example](https://github.com/google/sbom-conformance/blob/90ca76f58443ed99e09a21c848234d90910c8746/pkg/checkers/base/base_test.go#L311-L333)), which isn't ideal. Some of the tests use the wrong index ([example](https://github.com/google/sbom-conformance/blob/90ca76f58443ed99e09a21c848234d90910c8746/pkg/checkers/base/base_test.go#L360-L369))
- The tests are verbose - an individual error struct should be tested "atomically", not as multiple different assertions
- All of the test suites in `base_test.go` use the same SBOM, which makes them brittle.
- A lot of the tests in `base_test.go` don't print the actual result (e.g. [`t.Errorf("Wrong")`](https://github.com/google/sbom-conformance/blob/90ca76f58443ed99e09a21c848234d90910c8746/pkg/checkers/base/base_test.go#L588-L590)). Some print the wrong expected output ([example](https://github.com/google/sbom-conformance/blob/90ca76f58443ed99e09a21c848234d90910c8746/pkg/checkers/base/base_test.go#L342-L344)).
- The same thing things are tested in multiple places, which makes modification more difficult. One example of this is the [text summary](https://github.com/google/sbom-conformance/blob/90ca76f58443ed99e09a21c848234d90910c8746/pkg/checkers/base/base_test.go#L247) that is tested.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.