Skip to content

Unit Tests

bchavez edited this page Jun 10, 2019 · 4 revisions

Like the official Java driver, the C# driver also derives its Query Language Tests from the official rethinkdb\test\rql_test YAML tests.

The C# unit tests have been automatically converted from YAML to C# and reside inside:

  • Source\RethinkDb.Driver.Tests\Generated

You can simply run all the unit tests in RethinkDb.Driver.Tests to test the driver's correctness.

Updating Generated Tests

The generated unit tests can be updated. The process for updating the auto-generated unit tests requires from the Java driver source. The following process updates the C# generated tests from YAML files:

  1. Checkout the Java driver.

  2. Ensure you have java_term_info.json (if not read Getting Started on how to generate it).

  3. Copy our special YAML Test.yaml template to the Java driver's java\template\ directory. The template\Test.yaml file (from our repo) should be alongside template\ file in the Java driver folder.

  4. Make two edits to to ensure the Test.yaml file is used when generating test outputs.

    class TestFile(object): def render(self)
            'Test.yaml', //EDIT 1: from 
            output_name=self.module_name + '.yaml', //EDIT 2: from .java

    All we're doing here is using our template instead of the template to output the expected Java lines in ReQL.

  5. Next, run python3 in the Java driver's folder. The result of the command will result in a batch of YAML files in /src/test/java/gen/*.yaml.

  6. Copy /src/test/java/gen/*.yaml and overwrite all the YAML files in the C# driver's folder:

    • Source\Templates\UnitTests

    The fresh YAML files from the Java folder will be base64 encoded to keep non-ASCII characters intact and avoid complex character escape sequences when making the transition.

  7. Next, clean up and decode the imported YAML tests by running build yamlimport task. The YAML tasks should now be valid YAML tests with correct escape sequences and character encodings.

  8. Lastly, run build testgen to regenerate the C# tests in Source\RethinkDb.Driver.Tests\Generated from the newly imported YAML files.

You can’t perform that action at this time.