Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EDT:EUnit Testing"

(How to write test cases using EUnit)
Line 27: Line 27:
 
*Set the generators:<br>
 
*Set the generators:<br>
  
&nbsp; &nbsp; 1) If you run the testing on both Java and JavaScript platform, just leave the settings as default. That is, turn on both Java and JavaScript generator.<br>
+
&nbsp; &nbsp; 1) If you run the testing on both Java and JavaScript platform, just leave the settings as default. That is, turn on both Java and JavaScript generator.<br>  
  
&nbsp; &nbsp; 2) If you run the testing on a specific platform, select the checkbox "Override generation settings from workspace preferences" and choose a <br>
+
&nbsp; &nbsp; 2) If you run the testing on a specific platform, select the checkbox "Override generation settings from workspace preferences" and choose a generator.<br>  
 
+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; generator.<br>
+
  
 
2. Create an EGL Library, for example: test.egl, and give a package name "libs".<br>  
 
2. Create an EGL Library, for example: test.egl, and give a package name "libs".<br>  
  
3. Open the library with EGL Editor, remove the automatically generated code.<br>
+
3. Open the library with EGL Editor, remove the automatically generated code.<br>  
  
4. Type the variable declarations and functions(We treat each function as an EUnit test case) in the library, which should contains the annotation @Test. For example:<br>
+
4. Type the variable declarations and functions(We treat each function as an EUnit test case) in the library, which should contains the annotation @Test. For example:<br>  
 
<pre>package libs;
 
<pre>package libs;
 
import org.eclipse.edt.eunit.runtime.LogResult;
 
import org.eclipse.edt.eunit.runtime.LogResult;
Line 59: Line 57:
  
  
</pre>
+
</pre>  
 
*Tips<br>
 
*Tips<br>
  
&nbsp;&nbsp;&nbsp; If you want to disable some specific test cases, you can use "targetLang" in the annotation. For example, below is a test case which cannot be <br>
+
&nbsp;&nbsp;&nbsp; If you want to disable some specific test cases, you can use "targetLang" in the annotation. For example, below is a test case which cannot be generated into JavaScript.<br>  
 
+
&nbsp;&nbsp;&nbsp; generated into JavaScript.<br>
+
 
<pre> function runAssignmentFunction01(){@Test {targetLang = [JAVA]}}
 
<pre> function runAssignmentFunction01(){@Test {targetLang = [JAVA]}}
 
variation = "constant initialization";
 
variation = "constant initialization";
 
LogResult.assertStringEqual1("Fred Smith", constFlexName);
 
LogResult.assertStringEqual1("Fred Smith", constFlexName);
 
end
 
end
</pre>
+
</pre>  
 
<br>
 
<br>
  

Revision as of 04:08, 12 December 2011

EUnit Test Framework Overview

  • What is EUnit

EUnit stands for EGL Unit testing framework. It is a simple open source framework to write and run repeatable EGL tests.

Its features include:

  • Tooling to generate test runner and run the test cases – Provided by EDT Framework
    • Manually and Automated
    • Can be run as often as needed (on demand, nightly build)
    • GUI and command line interfaces
    • Logging, Reporting, Analyzing
    • Can be used in multiple language environment (java, javascript, etc)
  • Test Cases - Provided by test writters
  • Documentation - Provided by
    • What does each test case test

Design

How to write test cases using EUnit

1. Create an EGL Project, for example: eunit.test

  • Select "Basic" as the template.
  • Set the generators:

    1) If you run the testing on both Java and JavaScript platform, just leave the settings as default. That is, turn on both Java and JavaScript generator.

    2) If you run the testing on a specific platform, select the checkbox "Override generation settings from workspace preferences" and choose a generator.

2. Create an EGL Library, for example: test.egl, and give a package name "libs".

3. Open the library with EGL Editor, remove the automatically generated code.

4. Type the variable declarations and functions(We treat each function as an EUnit test case) in the library, which should contains the annotation @Test. For example:

package libs;
import org.eclipse.edt.eunit.runtime.LogResult;
import org.eclipse.edt.eunit.runtime.LogResult;
import org.eclipse.edt.eunit.runtime.Test;

// basic library
library test
	
	const constFlexName string = "Fred Smith";
	varFlexName string;
	variation string;
	
	function runAssignmentFunction01(){@Test {}}
		variation = "constant initialization";
		LogResult.assertStringEqual1("Fred Smith", constFlexName);
	end
	
end



  • Tips

    If you want to disable some specific test cases, you can use "targetLang" in the annotation. For example, below is a test case which cannot be generated into JavaScript.

	function runAssignmentFunction01(){@Test {targetLang = [JAVA]}}
		variation = "constant initialization";
		LogResult.assertStringEqual1("Fred Smith", constFlexName);
	end


How to run tests using EUnit



Back to the top