Documentation Home
Connectors and APIs Manual
Download this Manual
PDF (US Ltr) - 4.1Mb
PDF (A4) - 4.1Mb


3.3.5 Testing Connector/J

The Connector/J source code repository or packages that are shipped with source code include an extensive test suite, containing test cases that can be executed independently. The test cases are divided into the following categories:

  • Unit tests: They are methods located in packages aligning with the classes that they test.

  • Functional tests: Classes from the package testsuite.simple. Include test code for the main features of Connector/J.

  • Performance tests: Classes from the package testsuite.perf. Include test code to make measurements for the performance of Connector/J.

  • Regression tests: Classes from the package testsuite.regression. Includes code for testing bug and regression fixes.

  • X DevAPI and X Protocol tests: Classes from the package testsuite.x for testing X DevAPI and X Protocol functionality.

The bundled Ant build file contains targets like test, which can facilitate the process of running the Connector/J tests; see the target descriptions in the build file for details. To run the tests, in addition to fulfilling the requirements described in Section 3.3.3, “Installing from Source”, you must also set the following properties in the build.properties file or through the Ant -D options:

  • com.mysql.cj.testsuite.jvm: the JVM to be used for the tests. If the property is not set, the JVM supplied with com.mysql.cj.build.jdk will be used.

  • com.mysql.cj.testsuite.url: it specifies the JDBC URL for connection to a MySQL test server; see Section 3.5.2, “Connection URL Syntax”.

  • com.mysql.cj.testsuite.url.openssl: (for release 8.0.26 and earlier only) it specifies the JDBC URL for connection to a MySQL test server compiled with OpenSSL; see Section 3.5.2, “Connection URL Syntax”.

  • com.mysql.cj.testsuite.mysqlx.url: it specifies the X DevAPI URL for connection to a MySQL test server; see Section 3.5.2, “Connection URL Syntax”.

  • com.mysql.cj.testsuite.mysqlx.url.openssl: (for release 8.0.26 and earlier only) it specifies the X DevAPI URL for connection to a MySQL test server compiled with OpenSSL; see Section 3.5.2, “Connection URL Syntax”.

After setting these parameters, run the tests with Ant in the following ways:

  • Building the test target with ant test runs all test cases by default on a single server instance. If you want to run a particular test case, put the test's fully qualified class names in the com.mysql.cj.testsuite.test.class variable; for example:

    shell > ant -Dcom.mysql.cj.testsuite.test.class=testsuite.simple.StringUtilsTest test

    You can also run individual tests in a test case by specifying the names of the corresponding methods in the com.mysql.cj.testsuite.test.methods variable, separating multiple methods by commas; for example:

    shell > ant -Dcom.mysql.cj.testsuite.test.class=testsuite.simple.StringUtilsTest \
    -Dcom.mysql.cj.testsuite.test.methods=testIndexOfIgnoreCase,testGetBytes test

While the test results are partially reported by the console, complete reports in HTML and XML formats are provided. View the HTML report by opening buildtest/junit/report/index.html. XML version of the reports are located in the folder buildtest/junit.

Note

Going from Connector/J 5.1 to 8.0 and beyond, a number of Ant properties for testing Connector/J have been renamed or removed; see Section 3.3.4.1.5, “Change for Test Properties” for details.