<a id="unit-testing"></a>

# Unit testing

* [Checker](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/checker.md)
* [Unit test suite](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/unit-test-suite.md)
* [Util suite](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/util-suite.md)

> See also: [Write a unit test](https://documentation.ubuntu.com/juju/4.0/contributor/howto/write-a-unit-test.md#write-a-unit-test)

Unit testing `juju` uses the `go test` CLI and a test suite and check libary called [`tc`](https://github.com/juju/tc%22).

A typical unit testing package is placed alongside the code package that you want to test (in the same directory) and
consists of:

- A file `package_test.go`, which is the entrypoint to your unit testing.
- (OPTIONAL) A file `export_test.go`, which is used to access or modify some internal aspect of the package under test
  for the tests. Even though the file ends with `_test.go`, the package definition is the same as the normal source
  files. In this way, for the tests and only the tests, additional variables and functions can be defined for the
  package and used in the tests.
- Test files of the form `<code filename>_test.go`, which are collections of [unit test suites](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/unit-test-suite.md#unit-test-suite).

<!--
github.com/juju/juju/internal/provider/magic:

- magic1.go

- magic1_test.go

- magic2.go

- magic2_test.go

- magic3.go

- magic3_test.go

-->
<!-- to provide a checkers and assert methods for the test writers.\*\*-->
> See more:

> - [Unit test suite](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/unit-test-suite.md)
>   - [Util suite](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/util-suite.md)
> - [Checker](https://documentation.ubuntu.com/juju/4.0/contributor/reference/testing/unit-testing/checker.md)
