-
Notifications
You must be signed in to change notification settings - Fork 14
Repeatable Unit Tests
Successful repeatable unit tests require data that is the same with each run, as well as test constants (key values) that are used with every run. Solutions created from the harmony core solution templates include functionality that makes it easy to create a unit test project (see Unit Testing) and functionality that makes it easy to set up data and constants for repeatable unit testing.
With a solution created from the harmonycore template, the easiest way to ensure that unit tests are repeatable is to instruct Harmony Core to rebuild the data prior to each unit test run. You can do this by uncommenting the following CodeGen setting in regen.bat:
set ENABLE_CREATE_TEST_FILES=-define ENABLE_CREATE_TEST_FILES
This option replaces the data files in the directory specified by DATA_FOLDER
in UserDefinedTokens.tkn.
Note that this option requires both a .txt file and an XDL file for each data file.
As part of your build, you can copy test-ready versions of your ISAM files to the folder specified by DATA_FOLDER
in UserDefinedTokens.tkn. Because DATA_FOLDER
is used for a hierarchical search that starts from the current working directory, it is best to create a folder with the specified name in the Services.Test folder and then copy test-ready data (ISAM files) to that folder with each build. (The Services.Test folder is created by GodeGen when the ENABLE_UNIT_TEST_GENERATION
option is set in regen.bat.) If the data folder is in Services.Test, your web service won’t use that data for production operations.
Along with data that is always the same, repeatable unit tests require test constants—i.e., a set of key values that can be used repeatedly to verify that relations and operations are working correctly. These are supplied by TestConstants.Values.dbl, which is created by CodeGen in the Services.Test directory if the ENABLE_UNIT_TEST_GENERATION
option is set in regen.bat. This file is generated the first time you generate unit tests, but once this file has been edited, it will not be generated (i.e., your changes won't be overwritten). As generated, TestConstants.Values.dbl has meaningless default values. You must replace the default values with values that work for your data, and you must maintain this file.
-
Tutorial 2: Building a Service from Scratch
- Creating a Basic Solution
- Enabling OData Support
- Configuring Self Hosting
- Entity Collection Endpoints
- API Documentation
- Single Entity Endpoints
- OData Query Support
- Alternate Key Endpoints
- Expanding Relations
- Postman Tests
- Supporting CRUD Operations
- Adding a Primary Key Factory
- Adding Create Endpoints
- Adding Upsert Endpoints
- Adding Patch Endpoints
- Adding Delete Endpoints
-
Harmony Core Code Generator
-
OData Aware Tools
-
Advanced Topics
- CLI Tool Customization
- Adapters
- API Versioning
- Authentication
- Authorization
- Collection Counts
- Customization File
- Custom Field Types
- Custom File Specs
- Custom Properties
- Customizing Generated Code
- Deploying to Linux
- Dynamic Call Protocol
- Environment Variables
- Field Security
- File I/O
- Improving AppSettings Processing
- Logging
- Optimistic Concurrency
- Multi-Tenancy
- Publishing in IIS
- Repeatable Unit Tests
- Stored Procedure Routing
- Suppressing OData Metadata
- Traditional Bridge
- Unit Testing
- EF Core Optimization
- Updating a Harmony Core Solution
- Updating to 3.1.90
- Creating a new Release
-
Background Information