Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Set Up Unit Testing

This topic explains the actions you should take in setting up Unit Testing, after having downloaded and installed the JUnit and/or NUnit applications.

Topics

Topic

Detail

See also

Create Unit Test Stubs

By using the JUnit  or NUnit transformations and code generation you can create test method stubs for all of the public methods in each of your Classes.

 

( TestFixture )

public class CalculatorTest

{

 

 ( Test )

 public void testAdd(){

 

 }

 

 ( Test )

 public void testDivide(){

 

 }

 

 ( Test )

 public void testMultiply(){

         

 }

 

 ( Test )

 public void testSubtract(){

         

 }

}

 

Unit Testing

JUnit Transformation

NUnit Transformation

Generate Source Code

Define Test Cases

Write your unit test in the generated code stubs (either in Enterprise Architect or your preferred IDE).

The following is an NUnit example in C#, although it could also be any other .NET language, or Java and JUnit.

 

( TestFixture )

public class CalculatorTest

{

 

 ( Test )

 public void testAdd(){

         Assert.AreEqual(1+1,2);

 }

 

 ( Test )

 public void testDivide(){

         Assert.AreEqual(2/2,1);

 }

 

 ( Test )

 public void testMultiply(){

         Assert.AreEqual(1*1,1);

 }

 

 ( Test )

 public void testSubtract(){

         Assert.AreEqual(1-1,1);

 }

}

 

Alternatively, if you have not performed an xUnit transformation, you can reverse engineer the above code into Enterprise Architect so that Enterprise Architect can record all test results against this Class.

 

 

Compile Your Code

Ensure the source code being tested is compiled without errors, so that the test scripts can be run against it.

 

 

Set up the Test Scripts

Set up the Test scripts against the required package, and then run the tests.

Add Testing Command

Run Unit Tests

Learning Center topics

(Alt+F1) | Enterprise Architect | Execution Analysis | xUnit Tests | Set up Unit Tests