This repository is dedicated to learning about unit testing in Golang without relying on external packages. It provides valuable resources and examples to help you master the art of writing effective unit tests for your Go applications.
- Introduction
- Getting Started
- Writing Unit Tests
- Running Unit Tests
- Best Practices
- Additional Resources
- Contributing
- License
Unit testing is a crucial aspect of software development that ensures the reliability and correctness of your code. In this repository, you will learn how to write unit tests for your Golang code without the need for external testing packages.
To get started with unit testing in Golang, clone this repository to your local machine:
git clone https://github.com/tamathecxder/golang-unit-test.git
You will find a collection of code examples and test files to practice with in this repository.
In the "tests" directory, you will find examples of Go code and corresponding unit tests. Study these examples to understand how to structure and write unit tests for your Golang functions.
You can run unit tests using the go test command followed by the directory or files containing your test functions. For example:
go test ./tests
This command will execute all tests in the specified directory.
Explore the "best-practices" directory to discover recommended practices for writing effective unit tests. Understanding these best practices is crucial for ensuring your tests are meaningful and valuable.
In addition to the materials in this repository, you can further enhance your knowledge by exploring these resources:
Contributions are welcome! If you have any improvements, suggestions, or want to add more examples, please submit a pull request. We encourage you to participate in making this resource better.
The content in this repository is distributed under the MIT License. You are free to use, modify, and share the materials while giving proper attribution to the contributors.
Happy unit testing in Golang!