Skip to content

Trgan Test

TrganTest represents an individual test case within the trgan report. It can be created independently or nested inside a TrganContainer, depending on the desired report structure.

Standalone Tests

When modular grouping is not required, you can create a test directly on the report. This is ideal for flat reports that follow a scenario/test basis rather than a feature/test class hierarchy.

1
TrganTest test = trgan.CreateTest("Login with valid credentials");
You may optionally pass categories: string[] to tag the test with labels.
1
2
string[] categories = { "Login", "Smoke", "Critical" };
TrganTest test = trgan.CreateTest("Login with valid credentials", categories); 

Container-Based Tests

For structured reports that follow a Feature → Scenarios hierarchy (e.g., BDD or class-based TDD), use TrganContainer.CreateTest to nest the test inside a logical grouping.

1
2
3
TrganContainer container = trgan.CreateContainer("Login Feature");

TrganTest trganTest = container.CreateTest("Login with valid credentials");  
This approach enables hierarchical rendering, improved visual grouping within the report.

Note

When creating a TrganTest via TrganContainer, category tags cannot be passed directly to the test. Instead, they are inherited and validated through the associated TrganContainer.

Example:

1
2
3
4
5
TrganContainer container = trgan.CreateContainer("Login Feature");

TrganTest trganTest1 = container.CreateTest("Login with valid credentials");
TrganTest trganTest2 = container.CreateTest("Login with invalid credentials");
TrganTest trganTest3 = container.CreateTest("Login with valid old credentials");
all three trganTests are created under same TrganContainer object.