Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nitram509/golang-clean-test-code-showcase
https://github.com/nitram509/golang-clean-test-code-showcase
clean-code clean-code-example go golang hamcrest showcase test testing
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/nitram509/golang-clean-test-code-showcase
- Owner: nitram509
- License: mit
- Created: 2020-11-25T12:17:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-04T11:28:58.000Z (about 4 years ago)
- Last Synced: 2024-04-14T15:42:02.894Z (9 months ago)
- Topics: clean-code, clean-code-example, go, golang, hamcrest, showcase, test, testing
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# golang-clean-test-code-showcase
A showcase, of how unit test can be written.
No claim to be complete here.### Business requirement - for this demo purpose
This showcase/demo library has some acceptance criteria
* as a developer I would like to extract meaningful information from a condensed firmware string literal
* the information extraction must work on a single line string
* the information extraction must work on multi-line strings, separated by newline (\\n)
* these fields must be available in the meaningful extracted information (struct)
* FirmwareName,TargetName,TargetDetail,Version,ReleaseDateStr,GitHash,ReleaseTimeExample firmware String: \
```Betaflight / SPRACINGF3EVO (SPEV) 3.4.0 Apr 17 2018 / 14:00:13 (b2c247d34) MSP API: 1.39```### Implementations
1. Using native/vanilla GO language and library
2. Using famous [stretchr/testify](https://github.com/stretchr/testify) library
3. Using broken and outdated [rdrdr/hamcrest](https://github.com/rdrdr/hamcrest) library
4. Using almost unknown [corbym/gocrest](https://github.com/corbym/gocrest) library
* fun fact https://star-history.t9t.io/#corbym/gocrest### What is / Why "HAMCREST"?
[Hamcrest](http://hamcrest.org/) is a famous Java Library, that was developed to make
unit tests in Java more readable and follow [Clean Code principles](https://de.wikipedia.org/wiki/Clean_Code)Cite from hamcrest.org ... \
*Matchers that can be combined to create flexible expressions of intent* \
*Born in Java, Hamcrest now has implementations in a number of languages*