Difference between pages "FitnesseSlim" and "Fitnesse use in adempiere"

From ADempiere
(Difference between pages)
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
(SourceCode Notes)
 
 
Line 1: Line 1:
[[Image:FitnesseLoginPage.gif|thumb|440px|right|Wiki page with data to trigger setters and methods in ADempiereLogin.java - POC upgraded with Slim version of Fitnesse]]
+
== Test adempiere function use Fitnesse ==
=Background=
+
*This page follows and stands on the good work from [[TestFramework]].
+
*Here i recall how i researched to do a [[Cost Engine/Testing]] framework.
+
*The sourcecode for testing the following including the wiki page is online at:
+
**http://adempiere.svn.sourceforge.net/viewvc/adempiere/FitnesseSlim/
+
*Once you downloaded [http://www.fitnesse.org FitnesseSlim] (which is just the latest Fitnesse without any upgrading) and launch it via
+
java -jar fitnesse.jar -p 8080
+
  
 +
Install fitnesse and start it.
  
=WikiText=
+
At the index page add a test example "LoginGardenAdmin"
  
*From the Frontpage at your
+
"AdempiereSuite" -> "TestCashPosOrder" -> "TestLoginGardenAdmin".
http://localhost:8080/
+
*You can edit the FrontPage and create a sub-page i.e.
+
>LoginPage
+
*This will then lead to a new page for you to edit. You can put in following text:
+
<pre>
+
!define TEST_SYSTEM {slim}
+
!path /Users/red1/Documents/workspace/FitnesseSlim/bin
+
!path /Users/red1/Documents/projects/Fitnesse/fitnesse.jar
+
!path /Applications/Adempiere/lib/Adempiere.jar
+
!path /Applications/Adempiere/lib/AdempiereCLib.jar
+
  
|import|
+
Edit "TestLoginGardenAdmin" page,add test contents:
|fit|
+
  
!|ADempiere Login                                |
+
!|AdempiereLogin|
|User     |Password|Client|ClientID?|Role|execute?|
+
|User       |GardenAdmin|
|SuperUser|System |System|$p=      |0  |true   |
+
  |Password   |GardenAdmin|
|SuperUser|System|GardenWorld|$p=      |102 |true    |
+
|AD_ClIEnT_id|@Ref=AD_Client[Value='GardenWorld'].AD_Client_ID|
|GardenAdmin|GardenAdmin|GardenWorld|$p=      |0 |true    |
+
|AD_Role_id  |@Ref=AD_Role[Name='GardenWorld Admin'].AD_Role_ID|
|GardenAdmin|GardenAdmin|GardenWorld|$p=     |102 |true    |
+
|*Login*     |          |
|SuperUser|System|GardenWorld|$p=     |0 |true    |
+
</pre>
+
*On saving the page should look as shown at the top.
+
 
+
=POC for ADempiereLogin=
+
[[Image:FitnesseSlimLoginSuccess.gif|thumb|440px|right|A successful POC Login with easy user data to test true/false conditions. Just hit the ''Test'' button and get it intuitively on the same/single page.]]
+
*I reused CarlosRuiz's code and refactored them:
+
**r14692 /FitnesseSlim/src/fit/ (ADempiereLogin.java ModelLogin.java): Refactored ADempiereLogin as Fitnesse Fixture should not contain logic code but just Fixture data
+
**r14693 /FitnesseSlim/src/fit/ (ADempiereLogin.java ModelLogin.java): Fixture should not produce output, just true/false or assert types for Fitnesse final result.
+
**r14694 /FitnesseSlim/src/fit/ADempiereLogin.java: Fixture parse wiki input to be free from needing to put in @Ref tags, as column now correspond directly to Setter in java.
+
*Test are easily setup and the results are easily read:
+
 
+
=Developer Notes=
+
==WikiPage==
+
*As seen above, paths are put in the wikipage content to ensure the ADempiere jars are within its classpath during execution.
+
*There is no need to follow (in my case) the geneJar.desc instruction from Sunny at [[TestFramework]], as just pathing to ADempiere jar is sufficient.
+
*Sometimes Fitnesse intermittently misbehaves where new pages cannot be created or Debugger not triggering the breaks. It takes all sorts of restarting or test pages to get a feel of it. Suspect that too many conflicting edits may cause issues but once resolved they mysteriously do not recur.
+
==SourceCode==
+
*A big thanks to CarlosRuiz for the bulk of the gruntwork in making a proper testing code.
+
*The tests were trying to see which login info goes with which Role ID.
+
*Upon testing and debugging, i noted in my refactored code that the ADempiereInstance happens only once. This saves time for repeating rows to test.
+
**I ensured this by refactoring it into a superclass constructor:
+
<pre>
+
public ModelLogin() {
+
if (adempiereInstance == null) {
+
adempiereInstance = StaticAdempiereInstance.getInstance();
+
}
+
}
+
</pre>
+
*Furthermore the code (done by Carlos) only checks for different login info before relogin again.
+
<pre>
+
//Share login between different sessions
+
if (  m_ads != null
+
&& m_ads.isLoggedIn()
+
&& m_ads.getM_AD_Client_ID() == m_client_id
+
&& m_ads.getM_AD_Org_ID() == m_org_id
+
&& m_ads.getAD_Role_ID() == m_role_id
+
&& m_ads.getM_Warehouse_ID() == m_warehouse_id
+
&& m_ads.getUser().equals(m_user)
+
)
+
return true; // already logged with same data
+
</pre>
+
[[Category:Testing]]
+

Revision as of 01:14, 10 August 2009

Test adempiere function use Fitnesse

Install fitnesse and start it.

At the index page add a test example "LoginGardenAdmin"

"AdempiereSuite" -> "TestCashPosOrder" -> "TestLoginGardenAdmin".

Edit "TestLoginGardenAdmin" page,add test contents:

!|AdempiereLogin|
|User        |GardenAdmin|
|Password    |GardenAdmin|
|AD_ClIEnT_id|@Ref=AD_Client[Value='GardenWorld'].AD_Client_ID|
|AD_Role_id  |@Ref=AD_Role[Name='GardenWorld Admin'].AD_Role_ID|
|*Login*     |           |