Overview of all test frameworks

Any project usually needs a combination of multiple types of tests simultaneously: both unit and integration tests – the latter especially if there are user-facing features.

Unit testing

Unit tests are valuable to ensure that a single component or function operates as designed, regardless of how it was integrated from other components.

For unit testing, we use the Go test framework directly (testing.T and TestXXX functions in xx_test.go files; sometimes also Example_xxx functions)

  • Independent components can be exercised by instantiating them independently in a test.

  • Unit tests for SQL functionality can be exercised via the SQL logic test framework (see pkg/sql/logictest and dev testlogic)

  • Other unit tests that needs a functional SQL or KV layer can use TestServer and TestCluster.

    • Conversely, avoid using TestServer/TestCluster in unit tests that do not need a full SQL/KV layer. This will make the test run faster.

Integration testing

Integration tests are valuable to exercise a product journey as experienced by an end-user.

For integration testing, we use various testing frameworks.

Copyright (C) Cockroach Labs.
Attention: This documentation is provided on an "as is" basis, without warranties or conditions of any kind, either express or implied, including, without limitation, any warranties or conditions of title, non-infringement, merchantability, or fitness for a particular purpose.