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

MeindertN / RoboClerk / 14742685946

29 Apr 2025 10:37PM UTC coverage: 85.509% (-0.2%) from 85.705%
14742685946

push

github

MeindertN
fixed test

1224 of 1426 branches covered (85.83%)

Branch coverage included in aggregate %.

4122 of 4826 relevant lines covered (85.41%)

130.83 hits per line

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

91.43
/RoboClerk/ContentCreators/SoftwareSystemTest.cs
1
using Microsoft.CodeAnalysis.Scripting;
2
using RoboClerk.Configuration;
3
using System.Collections.Generic;
4
using System.Text;
5

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

14
        }
8✔
15

16
        private string CheckResults(List<LinkedItem> items, TraceEntity docTE)
17
        {
4✔
18
            StringBuilder errors = new StringBuilder();
4✔
19
            bool errorsFound = false;
4✔
20
            var results = data.GetAllTestResults();
4✔
21
            foreach (var item in items)
34✔
22
            {
11✔
23
                if (!((SoftwareSystemTestItem)item).TestCaseAutomated)
11✔
24
                {
4✔
25
                    continue;
4✔
26
                }
27
                bool found = false;
7✔
28
                foreach (var result in results)
38✔
29
                {
11✔
30
                    if (result.Type == TestResultType.SYSTEM && result.ID == item.ItemID)
11✔
31
                    {
5✔
32
                        found = true;
5✔
33
                        if (result.Status == TestResultStatus.FAIL)
5✔
34
                        {
1✔
35
                            errors.AppendLine($"* Test with ID \"{result.ID}\" has failed.");
1✔
36
                            errorsFound = true;
1✔
37
                        }
1✔
38
                        break;
5✔
39
                    }
40
                }
6✔
41
                if (!found)
7✔
42
                {
2✔
43
                    errorsFound = true;
2✔
44
                    errors.AppendLine($"* Result for test with ID \"{item.ItemID}\" not found in results.");
2✔
45
                }
2✔
46
            }
7✔
47
            foreach (var result in results)
32✔
48
            {
10✔
49
                if (result.Type != TestResultType.SYSTEM)
10✔
50
                    continue;
4✔
51
                bool found = false;
6✔
52
                foreach (var item in items)
31✔
53
                {
9✔
54
                    if (((SoftwareSystemTestItem)item).TestCaseAutomated && result.ID == item.ItemID)
9✔
55
                    {
5✔
56
                        found = true;
5✔
57
                        break;
5✔
58
                    }
59
                }
4✔
60
                if (!found)
6✔
61
                {
1✔
62
                    errorsFound = true;
1✔
63
                    errors.AppendLine($"* Result for test with ID \"{result.ID}\" found, but test plan does not contain such an automated test.");
1✔
64
                }
1✔
65
            }
6✔
66
            if (errorsFound)
4✔
67
            {
3✔
68
                errors.Insert(0, "RoboClerk detected problems with the automated testing:\n\n");
3✔
69
                errors.AppendLine();
3✔
70
                return errors.ToString();
3✔
71
            }
72
            else
73
            {
1✔
74
                return "All automated tests from the test plan were successfully executed and passed.";
1✔
75
            }
76
        }
4✔
77

78
        protected override string GenerateADocContent(RoboClerkTag tag, List<LinkedItem> items, TraceEntity sourceTE, TraceEntity docTE)
79
        {
7✔
80
            StringBuilder output = new StringBuilder();
7✔
81
            var dataShare = new ScriptingBridge(data, analysis, sourceTE);
7✔
82
            if (tag.HasParameter("CHECKRESULTS") && tag.GetParameterOrDefault("CHECKRESULTS").ToUpper() == "TRUE")
7✔
83
            {
4✔
84
                //this will go over all SYSTEM test results (if available) and prints a summary statement or a list of found issues.
85
                return CheckResults(items, docTE);
4✔
86
            }
87
            else
88
            {
3✔
89
                var file = data.GetTemplateFile(@"./ItemTemplates/SoftwareSystemTest_automated.adoc");
3✔
90
                var rendererAutomated = new ItemTemplateRenderer(file);
3✔
91
                file = data.GetTemplateFile(@"./ItemTemplates/SoftwareSystemTest_manual.adoc");
3✔
92
                var rendererManual = new ItemTemplateRenderer(file);
3✔
93
                foreach (var item in items)
15✔
94
                {
3✔
95
                    dataShare.Item = item;
3✔
96
                    SoftwareSystemTestItem tc = (SoftwareSystemTestItem)item;
3✔
97
                    var result = string.Empty;
3✔
98
                    if (tc.TestCaseAutomated)
3✔
99
                    {
1✔
100
                        try
101
                        {
1✔
102
                            result = rendererAutomated.RenderItemTemplate(dataShare);
1✔
103
                        }
1✔
104
                        catch (CompilationErrorException e)
×
105
                        {
×
106
                            logger.Error($"A compilation error occurred while compiling SoftwareSystemTest_automated.adoc script: {e.Message}");
×
107
                            throw;
×
108
                        }
109
                    }
1✔
110
                    else
111
                    {
2✔
112
                        if( tc.TestCaseToUnitTest )
2!
113
                        {
×
114
                            //trying to kick a manual test to the unit test plan is not correct. 
115
                            logger.Error($"Trying to test a manual {sourceTE.Name} ({tc.ItemID}) with a unit test is not valid.");
×
116
                            throw new System.InvalidOperationException($"Cannot kick manual test case {tc.ItemID} to unit test. Change test type to automated.");
×
117
                        }
118
                        try
119
                        {
2✔
120
                            result = rendererManual.RenderItemTemplate(dataShare);
2✔
121
                        }
2✔
122
                        catch (CompilationErrorException e)
×
123
                        {
×
124
                            logger.Error($"A compilation error occurred while compiling SoftwareSystemTest_manual.adoc script: {e.Message}");
×
125
                            throw;
×
126
                        }
127
                    }
2✔
128
                    output.Append(result);
3✔
129
                }
3✔
130
                ProcessTraces(docTE, dataShare);
3✔
131
            }
3✔
132
            return output.ToString();
3✔
133
        }
7✔
134
    }
135
}
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