Adichatz provides an original and easy to use solution for testing UI components.
* Based on [[http://testng.org|TestNG]] testing framework. * Launched automatically or on-demand from application (Test classes can be updated and relaunched). * Can easily simulate users actions. * Results are displayed and interpretable in specific editor.
\\ ==== How to test ==== === Step 1: Add 'org.adichatz.testing' plugin === **org.adichatz.testing** plugin must be added to application environment. * Open file $projectDirectory/META-INF/MANIFEST.MF. * add line org.adichatz.testing, in Require-Bundle item. \\ \\ If you try to relaunch the application, an error must occur.\\ java.lang.RuntimeException: No application id has been found. {{tutorial:add_testing_manifest.png?400 |Add 'org.adichatz.testing' plugin}} To overcome this problem, follow instructions below: * Select Run > Run configurations.... A new window is open, then: * Select Plug-ins tab. * Select Add Required Plug-ins button. * In the same window, select Run button. {{tutorial:add_required_plugins.png?500 |Add required plugins}} Remark:\\ An other way is to add missing plugins inside {plugin}/{projectName}.product file: * com.google.inject, * org.apache.ant. If you decide to add missing plugins inside {plugin}/{projectName}.product file, thing to delete these lines before exporting project. \\ \\ === Step 2: Create a Test class === A test case is composed of one or several Java classes with one ore several annoted methods.\\ Below, a simple Test class is described. Create java class MyFirstTest.java in package org.mycompany.myproject.testing. package org.mycompany.myproject.testing; import org.adichatz.engine.e4.core.PartCore; import org.adichatz.engine.e4.part.BoundedPart; import org.adichatz.engine.e4.resource.E4SimulationTools; import org.adichatz.engine.simulation.SimulationTools; import org.adichatz.testing.AdiAssert; import org.adichatz.testing.TestingTools; import org.testng.annotations.Test; public class MyFirstTest { @Test public void test() { // Select Option queriesMenus/filmQuery in navigator "groupNavigator" and return a part. BoundedPart filmQueryPart = E4SimulationTools.handleNavigatorOpenPartItem("groupNavigator", "queriesMenu", "filmQUERY"); // check that part is active. AdiAssert.isPartActive(filmQueryPart); TestingTools.testInfo("QueryForm with query 'filmQUERY' is active."); PartCore filmQueryCore = filmQueryPart.getGenCode(); // Launch query in filmQuery part. SimulationTools.handleContextMenuAction(filmQueryCore, "tableCM:contextMenu", "launchQueryAction"); } } Remarks:\\ This test opens a QueryForm editor and launch a query to supply rows to the Table Controller contained in the editor. * Line 12: @Test annotation points out a method to be launched by TestNG. * Line 15: Simulates selection of Query Film in navigator. * Line 22: Executes launchQueryAction item in context menu. \\ A more complex Test class which checks databinding between Entity editors could be seen [[testing_extensive|here]]. \\ \\ === Step 3: Create a file $projectDirectory/resources/xml/AdichatzTesting.xml as follow === You need to add an simple entry in file $projectDirectory/resources/xml/AdichatzTesting.xml as shown below: Remarks:\\ A testing * Line 1: means: A testing menu is added to existing navigators at runtime. The menu is expanded. * Line 2: A suite test case is created. The suite is expanded and is not launched automatically during the application startup process. \\ \\ === Step 4: Execute and reexecute tests === {{tutorial:testing_execute.png?400 |Execute a test}} To execute or reexecute a test case, click on the corresponding item (my first test). * when a test fails, a specific editor was created for reporting test results and is automatically open. * Changes done on Test classes in Eclipse IDE are directly considered without relaunching the application. \\ \\ === Step 5: Show results === {{tutorial:testing_results.png?600 |Display Testing results}}
A specific editor was created for reporting test results. By default, it is automatically open when a test fails. * A tree is used to report results. * Level Run: Displays the label of the suite or of the used testNG xml file. * Level Suite: Displays onStart event with main features: duration, sucesses, failures.... * Level Class: Display label for class or onFinish event. * Level Test: Reports main features or the Test (a method with annotation @Test): duration, sucesses, failures... \\ \\ === Tools === Testing menu provides Testing tools options as shown below:
{{tutorial:testing_tools.png?600 |Testing tools}} * Testing result manager: Opens and editor for reporting test results. * Display register for active editor: Display in the consol part all the entries of register for the active editor. These entries are used in Test class for naming controllers. * Refresh testing menu: Refresh current Testing menu. Changes made on IDE can be seen without having to quit the application. .