-
-
Notifications
You must be signed in to change notification settings - Fork 134
Unit Tests
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.
The generated unit tests can be updated. The process for updating the auto-generated unit tests requires convert_tests.py
from the Java driver source. The following process updates the C# generated tests from YAML files:
-
Checkout the Java driver.
-
Ensure you have
java_term_info.json
(if not read Getting Started on how to generate it). -
Copy our special YAML
Test.yaml
template to the Java driver'sjava\template\
directory. Thetemplate\Test.yaml
file (from our repo) should be alongsidetemplate\Test.java
file in the Java driver folder. -
Make two edits to
convert_test.py
to ensure theTest.yaml
file is used when generating test outputs.class TestFile(object): def render(self) .... self.renderer.render( 'Test.yaml', //EDIT 1: from Test.java output_dir=self.test_output_dir, output_name=self.module_name + '.yaml', //EDIT 2: from .java .... )
All we're doing here is using our template instead of the Test.java template to output the expected Java lines in ReQL.
-
Next, run
python3 convert_tests.py
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
. -
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.
-
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. -
Lastly, run
build testgen
to regenerate the C# tests inSource\RethinkDb.Driver.Tests\Generated
from the newly imported YAML files.
- Home
- Query Examples
- Logging
- Connections & Pooling
- Extra C# Features
- GOTCHA Goblins!
- LINQ to ReQL Provider
- Differences
- Java ReQL API Documentation