[etunit] Add classname attribute to converted JUnit XML reports

Some tools pick up on the classname attribute of test cases and ignore
the name of the test suite in JUnit XML reports.
Therefore we also write the name of the test suite to the classname
attribute of each test case.

Change-Id: I25be7cfe30e9426604c9062aa47cdc024be2ddfa
diff --git a/plugins/org.eclipse.etrice.etunit.converter/src/org/eclipse/etrice/etunit/converter/EtUnitReportConverter.java b/plugins/org.eclipse.etrice.etunit.converter/src/org/eclipse/etrice/etunit/converter/EtUnitReportConverter.java
index 09a7ddb..43a24f5 100644
--- a/plugins/org.eclipse.etrice.etunit.converter/src/org/eclipse/etrice/etunit/converter/EtUnitReportConverter.java
+++ b/plugins/org.eclipse.etrice.etunit.converter/src/org/eclipse/etrice/etunit/converter/EtUnitReportConverter.java
@@ -370,28 +370,32 @@
 	}
 	
 	protected DocumentRoot applyOptions(BaseOptions options, DocumentRoot root) {
-		if (root!=null && options.isReplaceSuiteName()) {
-			if (root.getTestsuites()!=null) {
-				if (root.getTestsuites().getTestsuite().size()==1) {
-					root.getTestsuites().getTestsuite().get(0).setName(options.getSuiteName());
+		if (root != null && root.getTestsuites() != null) {
+			List<TestsuiteType> suites = root.getTestsuites().getTestsuite();
+			if(options.isReplaceSuiteName()) {
+				if (suites.size()==1) {
+					suites.get(0).setName(options.getSuiteName());
 				}
 				else {
 					int i=0;
-					for (TestsuiteType suite : root.getTestsuites().getTestsuite()) {
+					for (TestsuiteType suite : suites) {
 						suite.setName(options.getSuiteName()+i);
 						++i;
 					}
 				}
 			}
-		}
-		if(root != null && options.isPrefixSuiteName()) {
-			if(root.getTestsuites() != null) {
-				for(TestsuiteType suite : root.getTestsuites().getTestsuite()) {
+			if(options.isPrefixSuiteName()) {
+				for(TestsuiteType suite : suites) {
 					suite.setName(options.getSuiteNamePrefix() + suite.getName());
 				}
 			}
+			// Also write the name of the test suite to the classname attribute of each test case
+			// because some tools pick up on this attribute and ignore suite names (e.g. GitLab).
+			for(TestsuiteType suite : suites) {
+				suite.getTestcase().forEach(tc -> tc.setClassname(suite.getName()));
+			}
 		}
-		
+			
 		return root;
 	}
 
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml b/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml
index f197cf9..737437b 100644
--- a/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml
+++ b/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml
@@ -1,28 +1,28 @@
 <?xml version="1.0" encoding="ASCII"?>
 <testsuites>
   <testsuite failures="0" name="TestMessage" tests="1" time="0.0">
-    <testcase name="TestEtMessage_testBasicMessage" time="0.0"/>
+    <testcase classname="TestMessage" name="TestEtMessage_testBasicMessage" time="0.0"/>
   </testsuite>
   <testsuite failures="1" name="TestEtMessageQueue" tests="2" time="0.187">
-    <testcase name="TestEtMessageQueue_testPushPop" time="0.0">
+    <testcase classname="TestEtMessageQueue" name="TestEtMessageQueue_testPushPop" time="0.0">
       <failure message="expected=334 actual=333">rcvMsg2->evtID: expected=334, actual=333
  at ..\src\runtime\TestEtMessageQueue.c:42</failure>
     </testcase>
-    <testcase name="TestEtMessageQueue_testMassiveMessaging" time="0.187"/>
+    <testcase classname="TestEtMessageQueue" name="TestEtMessageQueue_testMassiveMessaging" time="0.187"/>
   </testsuite>
   <testsuite failures="0" name="TestEtMessageService" skipped="2" tests="5" time="0.016">
-    <testcase name="TestEtMessageService_init" time="0.0"/>
-    <testcase name="TestEtMessageService_GetPushPopReturn" time="0.0"/>
-    <testcase name="TestEtMessageService_GetReturn" time="0.016"/>
-    <testcase name="TestEtMessageService_execute">
+    <testcase classname="TestEtMessageService" name="TestEtMessageService_init" time="0.0"/>
+    <testcase classname="TestEtMessageService" name="TestEtMessageService_GetPushPopReturn" time="0.0"/>
+    <testcase classname="TestEtMessageService" name="TestEtMessageService_GetReturn" time="0.016"/>
+    <testcase classname="TestEtMessageService" name="TestEtMessageService_execute">
       <skipped message="not &quot;working&quot;"/>
     </testcase>
-    <testcase name="TestEtMessageService_getMessagePoolLowWaterMark">
+    <testcase classname="TestEtMessageService" name="TestEtMessageService_getMessagePoolLowWaterMark">
       <skipped/>
     </testcase>
   </testsuite>
   <testsuite failures="0" name="TestEtUnit" tests="2" time="0.0">
-    <testcase name="TestEtUnit_Expect_Order" time="0.0"/>
-    <testcase name="TestEtUnit_Expect" time="0.0"/>
+    <testcase classname="TestEtUnit" name="TestEtUnit_Expect_Order" time="0.0"/>
+    <testcase classname="TestEtUnit" name="TestEtUnit_Expect" time="0.0"/>
   </testsuite>
 </testsuites>
\ No newline at end of file