Module 5: Test Collections, Code Coverage & Tips
Executing Test Collections
Test Collections allow you to run multiple unit tests in sequence for quicker feedback and easier integration into your development workflow.
Creating a Collection
- Click New Collection in the Test Hub toolbar.
- Enter a name (e.g., All Test Cases) and description.
- Click the Entries tab and add your unit tests using the arrow button.
- Click Save.
Running a Collection
- Click the Execute (lightning bolt) icon next to your collection.
- You'll be prompted: "Are you sure?" — optionally tick Measure Code Coverage.
- Click Yes to run.
Understanding Code Coverage
When you enable Measure Code Coverage, the Test Hub tracks which lines of TI code are actually executed during the test run.
| Colour | Meaning |
|---|---|
| 🟢 Green | Code was executed during the test run |
| 🔴 Red | Code was missed or bypassed during the test |
After the run, click the Coverage tab to see results per TI process. For example, Dim.Employee.AddNewEmployee shows 92% coverage — the line sDept=ATTRS('Department', pDept, 'Description'); was not hit, which could indicate:
- Obsolete or dead code
- Incorrect test data not triggering that branch
- A conditional logic issue
Importing and Exporting Collections
Collections can be shared between developers or migrated across environments (e.g., DEV → QA → UAT).
| Action | Steps |
|---|---|
| Export | Go to Test Collections → click the Export (upload arrow) icon → saves a JSON file |
| Import | Go to Test Collections → click the Import (download arrow) icon → select your JSON file → click Upload |
A sample collection with all 5 test cases from this course is available at:
https://downloads.cubewise.com/Arc/Hands-on/test-hub-collection-export.zip
Best Practice Tips
- Run processes with different values and parameters to ensure all code paths are tested.
- Include invalid values in test cases to test error-handling branches.
- Use Test Coverage regularly to identify untested conditional branches.
- Use the Clean Up section to always leave your TM1 model in a clean state after testing.
- Integrate test collection execution into your deployment workflow (DEV → QA → UAT).