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

MeindertN / RoboClerk / 19315366704

12 Nov 2025 05:53PM UTC coverage: 72.366% (-0.7%) from 73.034%
19315366704

push

github

MeindertN
WIP: Added support for listing template files for inclusion in other files, getting and changing the project configuration, refreshing the project (with or without tag calculations) and refreshing the project datasources. TODO: ensure the refresh works as expected in all plugins and add the ability to return the specifications and parameters for all content creators. For this, each individual content creator needs to be able to describe its own parameters.

1747 of 2521 branches covered (69.3%)

Branch coverage included in aggregate %.

61 of 71 new or added lines in 4 files covered. (85.92%)

239 existing lines in 13 files now uncovered.

5685 of 7749 relevant lines covered (73.36%)

54.75 hits per line

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

78.64
/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)
8✔
14
        {
8✔
15

16
        }
8✔
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.Type == TestResultType.SYSTEM && result.ID == item.ItemID) ||
11!
36
                         (item.TestCaseToUnitTest && result.Type == TestResultType.UNIT &&
11✔
37
                          item.LinkedItems.Any(o => o.LinkType == ItemLinkType.UnitTest && o.TargetID == result.ID)))
11!
38
                    {
5✔
39
                        found = true;
5✔
40
                        if (result.Status == TestResultStatus.FAIL)
5✔
41
                        {
1✔
42
                            errorItems.Add($"Test with ID \"{result.ID}\" 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.Type != TestResultType.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.ID == 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.ID}\" 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
        {
7✔
136
            StringBuilder output = new StringBuilder();
7✔
137
            var dataShare = new ScriptingBridge(data, analysis, sourceTE, configuration);
7✔
138
            if (tag.HasParameter("CHECKRESULTS") && tag.GetParameterOrDefault("CHECKRESULTS").ToUpper() == "TRUE")
7✔
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
            {
3✔
145
                var extension = (configuration.OutputFormat == "ASCIIDOC" ? "adoc" : "html");
3!
146
                
147
                // Setup automated test template with caching
148
                var automatedFileIdentifier = configuration.ProjectID + $"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_automated.{extension}";
3✔
149
                ItemTemplateRenderer rendererAutomated;
150
                if (ItemTemplateRenderer.ExistsInCache(automatedFileIdentifier))
3✔
151
                {
2✔
152
                    rendererAutomated = ItemTemplateRenderer.FromCachedTemplate(automatedFileIdentifier);
2✔
153
                }
2✔
154
                else
155
                {
1✔
156
                    var automatedFile = data.GetTemplateFile($"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_automated.{extension}");
1✔
157
                    rendererAutomated = ItemTemplateRenderer.FromString(automatedFile, automatedFileIdentifier);
1✔
158
                }
1✔
159
                
160
                // Setup manual test template with caching
161
                var manualFileIdentifier = configuration.ProjectID + $"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_manual.{extension}";
3✔
162
                ItemTemplateRenderer rendererManual;
163
                if (ItemTemplateRenderer.ExistsInCache(manualFileIdentifier))
3✔
164
                {
2✔
165
                    rendererManual = ItemTemplateRenderer.FromCachedTemplate(manualFileIdentifier);
2✔
166
                }
2✔
167
                else
168
                {
1✔
169
                    var manualFile = data.GetTemplateFile($"./ItemTemplates/{configuration.OutputFormat}/SoftwareSystemTest_manual.{extension}");
1✔
170
                    rendererManual = ItemTemplateRenderer.FromString(manualFile, manualFileIdentifier);
1✔
171
                }
1✔
172
                
173
                foreach (var item in items)
15✔
174
                {
3✔
175
                    dataShare.Item = item;
3✔
176
                    SoftwareSystemTestItem tc = (SoftwareSystemTestItem)item;
3✔
177
                    var result = string.Empty;
3✔
178
                    if (tc.TestCaseAutomated)
3✔
179
                    {
1✔
180
                        try
181
                        {
1✔
182
                            result = rendererAutomated.RenderItemTemplate(dataShare);
1✔
183
                        }
1✔
UNCOV
184
                        catch (CompilationErrorException e)
×
UNCOV
185
                        {
×
UNCOV
186
                            logger.Error($"A compilation error occurred while compiling SoftwareSystemTest_automated.adoc script: {e.Message}");
×
UNCOV
187
                            throw;
×
188
                        }
189
                    }
1✔
190
                    else
191
                    {
2✔
192
                        if (tc.TestCaseToUnitTest)
2!
UNCOV
193
                        {
×
194
                            //trying to kick a manual test to the unit test plan is not correct. 
UNCOV
195
                            logger.Error($"Trying to test a manual {sourceTE.Name} ({tc.ItemID}) with a unit test is not valid.");
×
UNCOV
196
                            throw new System.InvalidOperationException($"Cannot kick manual test case {tc.ItemID} to unit test. Change test type to automated.");
×
197
                        }
198
                        try
199
                        {
2✔
200
                            result = rendererManual.RenderItemTemplate(dataShare);
2✔
201
                        }
2✔
UNCOV
202
                        catch (CompilationErrorException e)
×
UNCOV
203
                        {
×
UNCOV
204
                            logger.Error($"A compilation error occurred while compiling SoftwareSystemTest_manual.adoc script: {e.Message}");
×
UNCOV
205
                            throw;
×
206
                        }
207
                    }
2✔
208
                    output.Append(result);
3✔
209
                }
3✔
210
                ProcessTraces(docTE, dataShare);
3✔
211
            }
3✔
212
            return output.ToString();
3✔
213
        }
7✔
214
    }
215
}
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