Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Boris on January 30, 2023, 11:58:18 pm

Title: Junit integration
Post by: Boris on January 30, 2023, 11:58:18 pm
Hi All,

I'm trying to perform automated tests of an Executable state machine simulation with Junit. I have managed to complete the following:
1. Created an executable state machine artifact.
2. Generated Java code from said artifact.
3. Manually tested the behavior of the state machine in executable mode by manually sending triggers via inputting "send" string into "Simulation output window.
4. I have performed a Junit transformation whereby test stubs are made.
5. I have written a test in this test stub and it works when tested via IntelliJ IDE.

However, when trying to merge Junit and Enterprise architect I have issues. I get the following output. It would appear that it does not recognize Junit util.

To resolve the issue, I have already:
- Imported Junit 4 Jar files into the bin folder of JDK - result: no improvement (https://github.com/junit-team/junit4/wiki/Download-and-Install)
- Imported Junit 4 Jar files into the Simulation output folder - result: no improvement
- Imported jar files as a Binary module... still no effect
- Modified class path at java home from "%JAVA_HOME%\bin\javac.exe" -g -d "./SimulationOutput" *.java to "%JAVA_HOME%\bin\javac.exe" -g -cp "%classpaths%;.\"  -d "./SimulationOutput" *.java

Result is always the following:

Code: [Select]
Started Build section
C:\Users\M0194351\Documents\Source code\EA 15 ESS V11>if not exist SimulationOutput mkdir SimulationOutput
C:\Users\M0194351\Documents\Source code\EA 15 ESS V11>"C:\Program Files\Java\jdk-17.0.5\bin\javac.exe" -g  -d "./SimulationOutput" *.java
OpsTest.java:1: error: package org.junit does not exist
import org.junit.Test;
                ^
OpsTest.java:10: error: package junit.framework does not exist
public class OpsTest extends junit.framework.TestCase {
                                            ^
TestRunner.java:1: error: package org.junit.runner does not exist
import org.junit.runner.JUnitCore;
                       ^
Etc...Etc

  symbol:   class Failure
  location: class TestRunner
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
13 errors
Completed Build section
Build succeeded
Completed script Simulation . StateMachine . Simulation . Java . Java

Title: Re: Junit integration
Post by: Eve on January 31, 2023, 08:35:21 am
Disclaimer, I haven't programmed in Java in something like 20 years.

I suspect your class path is wrong. You -cp argument uses %classpaths% instead of %classpath%.
Title: Re: Junit integration
Post by: Mauricio Moya (Arquesoft) on February 01, 2023, 01:00:16 am
Try adding the javac.exe not only to the CLASS_PATH but also to PATH