• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeindertN / RoboClerk / 19481929392

18 Nov 2025 10:05PM UTC coverage: 72.65% (+0.3%) from 72.366%
19481929392

push

github

MeindertN
Fixed failing test

2217 of 3233 branches covered (68.57%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 1 file covered. (100.0%)

526 existing lines in 15 files now uncovered.

6894 of 9308 relevant lines covered (74.07%)

96.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.18
/RoboClerk.Core/ContentCreators/SoftwareSystemTest.cs
1
using Microsoft.CodeAnalysis.Scripting;
2
using RoboClerk.Core.Configuration;
3
using RoboClerk.Core;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.Text;
7

8
namespace RoboClerk.ContentCreators
9
{
10
    public class SoftwareSystemTest : MultiItemContentCreator
11
    {
12
        public SoftwareSystemTest(IDataSources data, ITraceabilityAnalysis analysis, IConfiguration conf)
13
            : base(data, analysis, conf)
11✔
14
        {
11✔
15

16
        }
11✔
17

18
        private string CheckResults(List<LinkedItem> items, TraceEntity docTE)
19
        {
4✔
20
            var results = data.GetAllTestResults();
4✔
21
            var errorItems = new List<string>();
4✔
22
            bool errorsFound = false;
4✔
23
            
24
            // Collect all error messages (format-agnostic logic)
25
            foreach (var i in items)
34✔
26
            {
11✔
27
                SoftwareSystemTestItem item = (SoftwareSystemTestItem)i;
11✔
28
                if (!item.TestCaseAutomated)
11✔
29
                {
4✔
30
                    continue;
4✔
31
                }
32
                bool found = false;
7✔
33
                foreach (var result in results)
38✔
34
                {
11✔
35
                    if ( (result.ResultType == TestType.SYSTEM && result.TestID == item.ItemID) || 
11!
36
                         (item.TestCaseToUnitTest && result.ResultType == TestType.UNIT && 
11✔
37
                          item.LinkedItems.Any(o => o.LinkType == ItemLinkType.UnitTest && o.TargetID == result.TestID)) )
11!
38
                    {
5✔
39
                        found = true;
5✔
40
                        if (result.ResultStatus == TestResultStatus.FAIL)
5✔
41
                        {
1✔
42
                            errorItems.Add($"Test with ID \"{result.TestID}\" has failed.");
1✔
43
                            errorsFound = true;
1✔
44
                        }
1✔
45
                        break;
5✔
46
                    }
47
                }
6✔
48
                if (!found)
7✔
49
                {
2✔
50
                    errorsFound = true;
2✔
51
                    string additional = item.TestCaseToUnitTest ? "Unit test r" : "R";
2!
52
                    errorItems.Add($"{additional}esult for test with ID \"{item.ItemID}\" not found in results.");
2✔
53
                }
2✔
54
            }
7✔
55
            
56
            foreach (var result in results)
32✔
57
            {
10✔
58
                if (result.ResultType != TestType.SYSTEM)
10✔
59
                    continue;
4✔
60
                bool found = false;
6✔
61
                foreach (var item in items)
31✔
62
                {
9✔
63
                    if (((SoftwareSystemTestItem)item).TestCaseAutomated && result.TestID == item.ItemID)
9✔
64
                    {
5✔
65
                        found = true;
5✔
66
                        break;
5✔
67
                    }
68
                }
4✔
69
                if (!found)
6✔
70
                {
1✔
71
                    errorsFound = true;
1✔
72
                    errorItems.Add($"Result for test with ID \"{result.TestID}\" found, but test plan does not contain such an automated test.");
1✔
73
                }
1✔
74
            }
6✔
75

76
            // Generate format-specific output
77
            if (configuration.OutputFormat.ToUpper() == "HTML" || configuration.OutputFormat.ToUpper() == "DOCX")
4!
78
            {
×
79
                return GenerateHTMLCheckResults(errorsFound, errorItems);
×
80
            }
81
            else
82
            {
4✔
83
                return GenerateASCIIDocCheckResults(errorsFound, errorItems);
4✔
84
            }
85
        }
4✔
86

87
        private string GenerateASCIIDocCheckResults(bool errorsFound, List<string> errorItems)
88
        {
4✔
89
            StringBuilder sb = new StringBuilder();
4✔
90
            
91
            if (errorsFound)
4✔
92
            {
3✔
93
                sb.AppendLine("RoboClerk detected problems with the automated testing:\n");
3✔
94
                foreach (var error in errorItems)
17✔
95
                {
4✔
96
                    sb.AppendLine($"* {error}");
4✔
97
                }
4✔
98
                sb.AppendLine();
3✔
99
            }
3✔
100
            else
101
            {
1✔
102
                sb.AppendLine("All automated tests from the test plan were successfully executed and passed.");
1✔
103
            }
1✔
104
            
105
            return sb.ToString();
4✔
106
        }
4✔
107

108
        private string GenerateHTMLCheckResults(bool errorsFound, List<string> errorItems)
109
        {
×
110
            StringBuilder sb = new StringBuilder();
×
111
            
112
            if (errorsFound)
×
113
            {
×
114
                sb.AppendLine("<div>");
×
115
                sb.AppendLine("    <h3>RoboClerk detected problems with the automated testing:</h3>");
×
116
                sb.AppendLine("    <ul>");
×
117
                foreach (var error in errorItems)
×
118
                {
×
119
                    sb.AppendLine($"        <li>{error}</li>");
×
120
                }
×
121
                sb.AppendLine("    </ul>");
×
122
                sb.AppendLine("</div>");
×
123
            }
×
124
            else
125
            {
×
126
                sb.AppendLine("<div>");
×
127
                sb.AppendLine("    <p>All automated tests from the test plan were successfully executed and passed.</p>");
×
128
                sb.AppendLine("</div>");
×
129
            }
×
130
            
131
            return sb.ToString();
×
132
        }
×
133

134
        protected override string GenerateContent(IRoboClerkTag tag, List<LinkedItem> items, TraceEntity sourceTE, TraceEntity docTE)
135
        {
10✔
136
            StringBuilder output = new StringBuilder();
10✔
137
            var dataShare = CreateScriptingBridge(tag, sourceTE);
10✔
138
            if (tag.HasParameter("CHECKRESULTS") && tag.GetParameterOrDefault("CHECKRESULTS").ToUpper() == "TRUE")
10✔
139
            {
4✔
140
                //this will go over all SYSTEM test results (if available) and prints a summary statement or a list of found issues.
141
                return CheckResults(items, docTE);
4✔
142
            }
143
            else
144
            {
6✔
145
                var extension = (configuration.OutputFormat == "ASCIIDOC" ? "adoc" : "html");
6!
146
                if (tag.HasParameter("BRIEF") && tag.GetParameterOrDefault("BRIEF").ToUpper() == "TRUE")
6✔
147
                {
1✔
148
                    var briefFileIdentifier = configuration.ProjectID + $"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_brief.{extension}";
1✔
149
                    //this will print a brief list of all software system tests that Roboclerk knows about
150
                    dataShare.Items = items;
1✔
151
                    ItemTemplateRenderer briefRenderer;
152
                    if (ItemTemplateRenderer.ExistsInCache(briefFileIdentifier))
1!
UNCOV
153
                    {
×
UNCOV
154
                        briefRenderer = ItemTemplateRenderer.FromCachedTemplate(briefFileIdentifier);
×
UNCOV
155
                    }
×
156
                    else
157
                    {
1✔
158
                        var briefFile = data.GetTemplateFile($"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_brief.{extension}");
1✔
159
                        briefRenderer = ItemTemplateRenderer.FromString(briefFile, briefFileIdentifier);
1✔
160
                    }
1✔
161
                     
162
                    var result = briefRenderer.RenderItemTemplate(dataShare);
1✔
163
                    ProcessTraces(docTE, dataShare);
1✔
164
                    return result;
1✔
165
                }               
166
                // Setup automated test template with caching
167
                var automatedFileIdentifier = configuration.ProjectID + $"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_automated.{extension}";
5✔
168
                ItemTemplateRenderer rendererAutomated;
169
                if (ItemTemplateRenderer.ExistsInCache(automatedFileIdentifier))
5!
UNCOV
170
                {
×
UNCOV
171
                    rendererAutomated = ItemTemplateRenderer.FromCachedTemplate(automatedFileIdentifier);
×
UNCOV
172
                }
×
173
                else
174
                {
5✔
175
                    var automatedFile = data.GetTemplateFile($"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_automated.{extension}");
5✔
176
                    rendererAutomated = ItemTemplateRenderer.FromString(automatedFile, automatedFileIdentifier);
5✔
177
                }
5✔
178
                
179
                // Setup manual test template with caching
180
                var manualFileIdentifier = configuration.ProjectID + $"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_manual.{extension}";
5✔
181
                ItemTemplateRenderer rendererManual;
182
                if (ItemTemplateRenderer.ExistsInCache(manualFileIdentifier))
5!
UNCOV
183
                {
×
184
                    rendererManual = ItemTemplateRenderer.FromCachedTemplate(manualFileIdentifier);
×
185
                }
×
186
                else
187
                {
5✔
188
                    var manualFile = data.GetTemplateFile($"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_manual.{extension}");
5✔
189
                    rendererManual = ItemTemplateRenderer.FromString(manualFile, manualFileIdentifier);
5✔
190
                }
5✔
191
                
192
                foreach (var item in items)
26✔
193
                {
6✔
194
                    dataShare.Item = item;
6✔
195
                    SoftwareSystemTestItem tc = (SoftwareSystemTestItem)item;
6✔
196
                    var result = string.Empty;
6✔
197
                    if (tc.TestCaseAutomated)
6✔
198
                    {
2✔
199
                        try
200
                        {
2✔
201
                            result = rendererAutomated.RenderItemTemplate(dataShare);
2✔
202
                        }
2✔
203
                        catch (CompilationErrorException e)
×
204
                        {
×
205
                            logger.Error($"A compilation error occurred while compiling SoftwareSystemTest_automated.adoc script: {e.Message}");
×
UNCOV
206
                            throw;
×
207
                        }
208
                    }
2✔
209
                    else
210
                    {
4✔
211
                        if (tc.TestCaseToUnitTest)
4✔
212
                        {
1✔
213
                            //trying to kick a manual test to the unit test plan is not correct. 
214
                            logger.Error($"Trying to test a manual {sourceTE.Name} ({tc.ItemID}) with a unit test is not valid.");
1✔
215
                            throw new System.InvalidOperationException($"Cannot kick manual test case {tc.ItemID} to unit test. Change test type to automated.");
1✔
216
                        }
217
                        try
218
                        {
3✔
219
                            result = rendererManual.RenderItemTemplate(dataShare);
3✔
220
                        }
3✔
UNCOV
221
                        catch (CompilationErrorException e)
×
UNCOV
222
                        {
×
UNCOV
223
                            logger.Error($"A compilation error occurred while compiling SoftwareSystemTest_manual.adoc script: {e.Message}");
×
UNCOV
224
                            throw;
×
225
                        }
226
                    }
3✔
227
                    output.Append(result);
5✔
228
                }
5✔
229
                ProcessTraces(docTE, dataShare);
4✔
230
            }
4✔
231
            return output.ToString();
4✔
232
        }
9✔
233
    }
234
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc