Ecosyste.ms: Funds
An open API service for providing issue and pull request metadata for open source projects.
https://github.com/frankban/quicktest
assertions go golang library testing
Last synced: about 4 hours ago
Repository metadata:
Quick helpers for testing Go applications
- Host: GitHub
- URL: https://github.com/frankban/quicktest
- Owner: frankban
- License: mit
- Created: 2017-09-14T12:56:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T18:34:33.000Z (8 months ago)
- Last Synced: 2024-10-18T15:19:36.247Z (23 days ago)
- Topics: assertions, go, golang, library, testing
- Language: Go
- Homepage:
- Size: 321 KB
- Stars: 528
- Watchers: 5
- Forks: 27
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Owner metadata:
- Name: Francesco Banconi
- Login: frankban
- Email:
- Kind: user
- Description:
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1408172?v=4
- Repositories: 77
- Last Synced at: 2024-04-16T05:41:12.977Z
- Profile URL: https://github.com/frankban
- Sponsor URL:
Committers metadata
Last synced: about 7 hours ago
Total Commits: 197
Total Committers: 18
Avg Commits per committer: 10.944
Development Distribution Score (DDS): 0.477
Commits in past year: 1
Committers in past year: 1
Avg Commits per committer in past year: 1.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
Francesco Banconi | f****i@c****m | 103 |
Mark Severson | m****k@k****o | 24 |
Roger Peppe | r****e@g****m | 17 |
dependabot[bot] | 4****] | 14 |
Dan Gillis | g****t@g****m | 7 |
Olivier Mengué | d****n@c****g | 7 |
komuW | k****5@g****m | 6 |
Kir Kolyshkin | k****n@g****m | 5 |
Rasmus Karlsson | r****n@p****m | 4 |
Martin Hilton | m****n@c****m | 2 |
Anthony Fok | f****a@d****g | 1 |
Bjørn Erik Pedersen | b****n@g****m | 1 |
Daniel Martí | m****n@m****c | 1 |
Francesco Banconi | f****n@g****m | 1 |
Joe Tsai | j****i@d****t | 1 |
Lorenz Bauer | l****b@i****m | 1 |
nagesh-ibm-power | 7****r | 1 |
Mark Severson | m****a@g****m | 1 |
Issue and Pull Request metadata
Last synced: 1 day ago
Package metadata
- Total packages: 1
- Total downloads: unknown
- Total docker downloads: 78,550,696
- Total dependent packages: 4,084
- Total dependent repositories: 40,418
- Total versions: 40
go: github.com/frankban/quicktest
Package quicktest provides a collection of Go helpers for writing tests. Quicktest helpers can be easily integrated inside regular Go tests, for instance: An assertion looks like this, where qt.Equals could be replaced by any available checker. If the assertion fails, the underlying Fatal method is called to describe the error and abort the test. If you don’t want to abort on failure, use Check instead, which calls Error instead of Fatal: For really short tests, the extra line for instantiating *qt.C can be avoided: The library provides some base checkers like Equals, DeepEquals, Matches, ErrorMatches, IsNil and others. More can be added by implementing the Checker interface. Below, we list the checkers implemented by the package in alphabetical order. All returns a Checker that uses the given checker to check elements of slice or array or the values of a map. It succeeds if all elements pass the check. On failure it prints the error from the first index that failed. For example: See also Any and Contains. Any returns a Checker that uses the given checker to check elements of a slice or array or the values from a map. It succeeds if any element passes the check. For example: See also All and Contains. CmpEquals checks equality of two arbitrary values according to the provided compare options. DeepEquals is more commonly used when no compare options are required. Example calls: CodecEquals returns a checker that checks for codec value equivalence. It expects two arguments: a byte slice or a string containing some codec-marshaled data, and a Go value. It uses unmarshal to unmarshal the data into an interface{} value. It marshals the Go value using marshal, then unmarshals the result into an interface{} value. It then checks that the two interface{} values are deep-equal to one another, using CmpEquals(opts) to perform the check. See JSONEquals for an example of this in use. Contains checks that a map, slice, array or string contains a value. It's the same as using Any(Equals), except that it has a special case for strings - if the first argument is a string, the second argument must also be a string and strings.Contains will be used. For example: ContentEquals is is like DeepEquals but any slices in the compared values will be sorted before being compared. For example: DeepEquals checks that two arbitrary values are deeply equal. The comparison is done using the github.com/google/go-cmp/cmp package. When comparing structs, by default no exported fields are allowed. If a more sophisticated comparison is required, use CmpEquals (see below). Example call: Equals checks that two values are equal, as compared with Go's == operator. For instance: Note that the following will fail: Use the IsNil checker below for this kind of nil check. ErrorAs checks that the error is or wraps a specific error type. If so, it assigns it to the provided pointer. This is analogous to calling errors.As. For instance: ErrorIs checks that the error is or wraps a specific error value. This is analogous to calling errors.Is. For instance: ErrorMatches checks that the provided value is an error whose message matches the provided regular expression. For instance: HasLen checks that the provided value has the given length. For instance: Implements checks that the provided value implements an interface. The interface is specified with a pointer to an interface variable. For instance: IsFalse checks that the provided value is false. The value must have a boolean underlying type. For instance: IsNil checks that the provided value is nil. For instance: As a special case, if the value is nil but implements the error interface, it is still considered to be non-nil. This means that IsNil will fail on an error value that happens to have an underlying nil value, because that's invariably a mistake. See https://golang.org/doc/faq#nil_error. So it's just fine to check an error like this: IsNotNil is a Checker checking that the provided value is not nil. IsNotNil is the equivalent of qt.Not(qt.IsNil) For instance: IsTrue checks that the provided value is true. The value must have a boolean underlying type. For instance: JSONEquals checks whether a byte slice or string is JSON-equivalent to a Go value. See CodecEquals for more information. It uses DeepEquals to do the comparison. If a more sophisticated comparison is required, use CodecEquals directly. For instance: Matches checks that a string or result of calling the String method (if the value implements fmt.Stringer) matches the provided regular expression. For instance: Not returns a Checker negating the given Checker. For instance: PanicMatches checks that the provided function panics with a message matching the provided regular expression. For instance: Satisfies checks that the provided value, when used as argument of the provided predicate function, causes the function to return true. The function must be of type func(T) bool, having got assignable to T. For instance: The testing.TB.Cleanup helper provides the ability to defer the execution of functions that will be run when the test completes. This is often useful for creating OS-level resources such as temporary directories (see c.Mkdir). When targeting Go versions that don't have Cleanup (< 1.14), the same can be achieved using c.Defer. In this case, to trigger the deferred behavior, calling c.Done is required. For instance, if you create a *C instance at the top level, you’ll have to add a defer to trigger the cleanups at the end of the test: However, if you use quicktest to create a subtest, Done will be called automatically at the end of that subtest. For example: The c.Patch, c.Setenv, c.Unsetenv and c.Mkdir helpers use t.Cleanup for cleaning up resources when available, and fall back to Defer otherwise.
- Homepage: https://github.com/frankban/quicktest
- Documentation: https://pkg.go.dev/github.com/frankban/quicktest#section-documentation
- Licenses: MIT
- Latest release: v1.14.6 (published over 1 year ago)
- Last Synced: 2024-11-09T00:08:31.381Z (1 day ago)
- Versions: 40
- Dependent Packages: 4,084
- Dependent Repositories: 40,418
- Docker Downloads: 78,550,696
-
Rankings:
- Dependent repos count: 0.028%
- Dependent packages count: 0.057%
- Docker downloads count: 0.348%
- Average: 1.528%
- Stargazers count: 2.674%
- Forks count: 4.534%
Dependencies
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-go v3 composite
- github.com/google/go-cmp v0.5.9
- github.com/kr/pretty v0.3.1
- github.com/creack/pty v1.1.9
- github.com/google/go-cmp v0.5.9
- github.com/kr/pretty v0.3.1
- github.com/kr/text v0.2.0
- github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
- github.com/rogpeppe/go-internal v1.9.0