/
Overview of all test frameworks

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.

  • To exercise user-facing automatable functionality, using standard SQL client drivers, we use the roachtest framework.

  • To exercise user-facing interactive functionality, we have two test approaches:

    • To exercise interactions in a text terminal, we use the TCL interactive test suite (pkg/cli/interactive_tests)

    • To exercise interactions via a web browser, we use a standard javascript interactive test package (somewhere in pkg/ui)

  • To exercise non-standard SQL drivers and certain system libraries, we use:

Related content

TestServer and TestCluster
TestServer and TestCluster
More like this
Building and running tests
Building and running tests
More like this
How to investigate a Go test failure
How to investigate a Go test failure
Read with this
Roachtest vs TestServer/TestCluster
Roachtest vs TestServer/TestCluster
More like this

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.