Skip to content

Commit cbf38d1

Browse files
committed
Enhanced test report: file-wise grouping, coverage at top, header display
- Group tests by source file/class: parse TRX TestDefinitions for className, add ByClass grouping, and render sections as e.g. Contentstack001_LoginTest.cs with tests listed under each. Fall back to ByAssembly when no class info. - Show "All files" code coverage at top: move the overall coverage block (Statements, Branches, Functions, Lines) to appear right after the test summary so it’s visible without scrolling. Code coverage section below contains only the per-file table. - Improve code coverage UI: dedicated All files card with clear labels, per-file table with caption and improved spacing, and color cues for low/mid coverage (red/yellow). Table shows File, Statements, Branches, Functions, Lines, and Uncovered line #s in a clear layout. - Render request/response headers in a single block: display headers as "name: value" lines in a <pre> block when tests supply header data, for a consistent, readable format.
1 parent 2932c6c commit cbf38d1

24 files changed

+4593
-389
lines changed

.github/workflows/unit-test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ jobs:
2020
name: DotNet unit Tests
2121
path: ./Contentstack.Management.Core.Unit.Tests/TestResults/Report-Contentstack-DotNet-Test-Case.trx
2222
reporter: dotnet-trx
23-
fail-on-error: true
23+
fail-on-error: true
24+
- name: Upload enhanced test report
25+
uses: actions/upload-artifact@v4
26+
if: success() || failure()
27+
with:
28+
name: enhanced-test-report
29+
path: Contentstack.Management.Core.Unit.Tests/TestResults/EnhancedReport-Contentstack-DotNet-Test-Case.html

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack001_LoginTest.cs

Lines changed: 332 additions & 107 deletions
Large diffs are not rendered by default.

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack002_OrganisationTest.cs

Lines changed: 314 additions & 30 deletions
Large diffs are not rendered by default.

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack003_StackTest.cs

Lines changed: 234 additions & 4 deletions
Large diffs are not rendered by default.

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack004_ReleaseTest.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ public class Contentstack004_ReleaseTest
2121
[TestInitialize]
2222
public async Task Initialize()
2323
{
24+
TestReportHelper.Begin();
2425
StackResponse response = StackResponse.getStack(Contentstack.Client.serializer);
2526
_stack = Contentstack.Client.Stack(response.Stack.APIKey);
2627
}
2728

29+
[TestCleanup]
30+
public void Cleanup()
31+
{
32+
TestReportHelper.Flush();
33+
}
34+
2835

2936

3037
/// <summary>
@@ -63,13 +70,19 @@ private string CreateTestRelease()
6370
public void Test001_Should_Create_Release()
6471
{
6572
string releaseUid = null;
73+
var sw = System.Diagnostics.Stopwatch.StartNew();
6674
try
6775
{
6876
releaseUid = CreateTestRelease();
6977

7078
Assert.IsNotNull(releaseUid);
71-
79+
80+
TestReportHelper.LogRequest("_stack.Release().Create() + Fetch()", "GET",
81+
$"https://{Contentstack.Client.contentstackOptions.Host}/v3/stacks/releases/{releaseUid}");
7282
ContentstackResponse contentstackResponse = _stack.Release(releaseUid).Fetch();
83+
sw.Stop();
84+
TestReportHelper.LogResponse((int)contentstackResponse.StatusCode,
85+
contentstackResponse.StatusCode.ToString(), sw.ElapsedMilliseconds, contentstackResponse.OpenResponse());
7386
var response = contentstackResponse.OpenJObjectResponse();
7487

7588
Assert.IsNotNull(response);
@@ -916,6 +929,7 @@ public async Task Test018_Should_Handle_Release_Not_Found_Async()
916929
[DoNotParallelize]
917930
public void Test019_Should_Delete_Release()
918931
{
932+
var sw = System.Diagnostics.Stopwatch.StartNew();
919933
try
920934
{
921935
var releaseModel = new ReleaseModel
@@ -930,13 +944,22 @@ public void Test019_Should_Delete_Release()
930944
var createResponseJson = createResponse.OpenJObjectResponse();
931945
string releaseToDeleteUid = createResponseJson["release"]["uid"].ToString();
932946

947+
TestReportHelper.LogRequest("_stack.Release(uid).Delete()", "DELETE",
948+
$"https://{Contentstack.Client.contentstackOptions.Host}/v3/stacks/releases/{releaseToDeleteUid}");
933949
ContentstackResponse contentstackResponse = _stack.Release(releaseToDeleteUid).Delete();
950+
sw.Stop();
951+
TestReportHelper.LogResponse((int)contentstackResponse.StatusCode,
952+
contentstackResponse.StatusCode.ToString(), sw.ElapsedMilliseconds, contentstackResponse.OpenResponse());
934953

954+
TestReportHelper.LogAssertion(contentstackResponse != null, "Response not null", type: "IsNotNull");
955+
TestReportHelper.LogAssertion(contentstackResponse.IsSuccessStatusCode, "Response is successful", type: "IsTrue");
935956
Assert.IsNotNull(contentstackResponse);
936957
Assert.IsTrue(contentstackResponse.IsSuccessStatusCode);
937958
}
938959
catch (Exception e)
939960
{
961+
sw.Stop();
962+
TestReportHelper.LogAssertion(false, $"Exception: {e.GetType().Name}{e.Message}", type: "Fail");
940963
Assert.Fail($"Delete release failed: {e.Message}");
941964
}
942965
}

0 commit comments

Comments
 (0)