Adempiere Junit test

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Adempiere Junit test

Test Junit and make it work. Adempiere Junit test code is here: http://adempiere.svn.sourceforge.net/viewvc/adempiere/trunk/extend/src/test/


Adempiere Junit test code

Adju.png

the codes in functional extend class AdempiereTestCase.and class AdempiereTestCase extends TestCase.

Junit test

  • First import adempiereTrunk source code into eclipse,build it.

Test

  • The source codes of them at project adempiereTrunk -> extend/src -> test,test.functional,test.functional.inventory and test.performance.
  • The compiled codes at adempiereTrunk -> extend -> build -> test

Test example

Adju1.png
  • Open test.functional -> AlertTest.java
  • Right click it, select Run As -> JUnit Test,we will get information like follow at the console.
  • And pop up a window let you select "test.properties" file.
  • If we did not appoint test.properties file,the test will fail.
Adju2.png

Review the failure Trace

Adju3.png
  • Then use the "test.properties" file, and test again.
# cp test.properties.template test.properties

Edit it like this:

# nano test.properties
Adju4.png
  • Save it to AdempiereProperties as the properties file when you installed adempiere.

Note: Here you can put "test.properties" file to directory adempiere_Home/,codes will find it automatically when testing.

Test again

right click test.functional -> AlertTest.java,select Run As -> JUnit Test

appoint the "test.properties" file,hit the open button.

Adju5.png
  • We will see the informations at console and the test result with 0 errors.
Adju6.png

Functional Test Suite

There is a class test.functional -> FunctionalTestSuite.java, a test suite for most of classes in test.functional.

FunctionalTestSuite.java

Adju7.png
  • run it as JUnit.

The result

Adju8.png

All tests successful

  • For classes such as AlertTest, MInvoiceTest,MMatchInvTest, MProductTest, MSessionTest, PackOutTest, WorkflowTest that are not in the test suite, we can add them to FunctionalTestSuite.java

Example add class AlertTest

suite.addTestSuite(AlertTest.class);
  • If you want to run all tests in adempiere.right click project adempiereTrunk -> Run,and select it as follow.
Adju9.png
  • Then hit run button.

Links