06.10.2015 Views

iDempiere FitNesse!

x6Z5SG

x6Z5SG

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

!<br />

!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong>!<br />

!<br />

Copyright (C) 2015 Redhuan D. Oon !<br />

THIS IS AN IROSES* QUALITY ASSURANCE PAPER TO PROMOTE A<br />

HIGH STANDARD OF PROFESSIONAL ERP IMPLEMENTATION. FREE<br />

DISTRIBUTION AND TRANSLATION ALLOWED AS LONG AS ORIGINAL<br />

COPYRIGHT(S) REMAINS INTACT!<br />

!<br />

!<br />

!<br />

*IROSES IS A JOINT BRAIN-CHILD UNDER FORMATION WITH A HUGE<br />

FAN AND FRIEND, A LARGE IDEMPIERE USER AND CONTRIBUTOR TO<br />

GERMAN LOCALISATION, HERR ANDREAS THIEL, RESIDING IN<br />

SAARBRÜCKEN, GERMANY. THIS IS THE LINK TO HIS CONTRIBUTION -<br />

HTTP://WIKI.IDEMPIERE.ORG/EN/AULERSIPEL HEIL THIEL!


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong>!<br />

Testing Framework for ERP Software Excellence<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

By:!<br />

Redhuan D. Oon aka red1.!<br />

(Paper started in early September, 2015 in Mexico City, an hour<br />

away from Victor Perez, in Pachuka, who took offence of my<br />

blistering testing reviews on his Libero modules to the extent of<br />

removing my name from the history page of ADempiere wiki and<br />

putting himself in my place instead. He phoned me up on hearing I<br />

have landed, to say, ‘Hola soy amigo!’).!<br />

October 5, 2015!<br />

version 0.5 !<br />

This paper is part of a testing series that covers many plugins such<br />

as German Localisation, Forecasting, Budgeting, Manufacturing,<br />

POS Integration, Mobile Integration and Warehouse Management.!<br />

It also includes an introductory operational guide to the new<br />

Forecasting module (pages 25-36).!<br />

Much gratitude to Zeeshan Hasan, of SYSNOVA, Bangladesh, for<br />

his unwavering long term support.!<br />

!<br />

!<br />

RED1’s THREE LAWS:<br />

Information is Free<br />

YOU HAVE TO KNOW<br />

People are Not<br />

YOU HAVE TO PAY<br />

Contributors are Priceless<br />

YOU HAVE TO BE<br />

any comment or feedback over the content of this material can be<br />

emailed to me at red1org@gmail.com or red1@red1.org or<br />

red1@adempiere.org <br />

Page<br />

2 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

sponsored by<br />

BANGLADESH<br />

!<br />

IT IS BEST THAT ANY REQUEST FOR ASSISTANCE BE MADE<br />

TO THE OPEN COMMUNITY OR THROUGH FORUMS. WE ARE<br />

MORE EFFECTIVE IN HELPING YOU COLLECTIVELY RATHER<br />

THAN SINGULARLY. PLEASE BE CONSIDERATE BY<br />

CONTRIBUTING BACK OR SPONSORING OTHER WORKS AND<br />

ANY OF THE CONTRIBUTORS. YOU BE APPRECIATED ALSO.<br />

Page<br />

3 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

!<br />

!<br />

!<br />

Table of Contents!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Something About Me! 6!<br />

Best Open Source Application! 8!<br />

Importance of Testing! 9!<br />

Features! 11!<br />

My Roll Back Improvement! 12!<br />

Create Record Auto! 13!<br />

Handling Info Window! 14!<br />

Developer User Guide! 15!<br />

Developer Setup! 15!<br />

Create A New Test! 15!<br />

Roll Back Or Commit Option ! 18!<br />

Read Record! 19!<br />

Location of Fixture Story! 20!<br />

Location of Source-Code! 20!<br />

Ready-Made Test Suite! 21!<br />

Quick Test! 21!<br />

Test Cash POS Order! 22!<br />

Run Process! 23!<br />

Assert Record! 23!<br />

Assert Variable! 24!<br />

Forecasting! 25!<br />

Reusing Forecast Model! 26!<br />

Forecast Menu Structure! 27!<br />

Sales Plan Info Window! 28!<br />

Testing Budget to Sales Forecast ! 29!<br />

Purchasing Forecast Info Window! 30!<br />

Testing PO Forecast to PO! 31!<br />

Testing Sales Order to Forecast! 32!<br />

Testing Forecast Model Processing! 33!<br />

Putting It All Together! 36!<br />

German Localisation ! 37!<br />

Manufacturing! 38!<br />

Page<br />

4 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

!<br />

!<br />

<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Warehousing! 39!<br />

Point of Sales! 40!<br />

Mobile Apps! 41<br />

Page<br />

5 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Something About Me!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

There is something that you might not know about me. I am in fact one of the rarest<br />

certified testing expert around. Yes, I have the certificate here to prove it. So please.. !<br />

!<br />

As you can see, it even gives me the authority to put on my sheriff’s badge. I will go and<br />

make one and wear it to walk around whenever there is a software failure around town.<br />

The CTFL may be quite some time ago and may have expired. But the last time I<br />

checked, the testing doctrine is the same. !<br />

Anyway, what did I learn during the course before passing the exams for this certificate?<br />

So here it is, the few major things that surprised during the course.!<br />

1. Thou shall test. Would you get on board a plane that is not tested? Of course it is<br />

tested, everyone assumed. Otherwise it will not fly.!<br />

2. Testing is more expensive than development. Yes, you hear me right. Or I have<br />

heard the lecturer wrong. At Microsoft, there are 5 testers to each developer, and in<br />

Adobe, there are 20 testers to each developer.!<br />

3. Testing actually begins with the review of requirements specifications. Yes, again,<br />

you hear me right. It does not begin with the code. If something is not specified<br />

correctly, without documentation then what the heck are you testing the code for?!<br />

Page<br />

6 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

4. Each testing opportunity cost should be calculated and specified. If a certain test is<br />

not taken what will be the cost of that piece of code failing? What is the insurance<br />

premium on it? If a Sales Order is faulty, how much does the user stand to lose? A<br />

security camera guarding a dog fails, or guarding the bank vault fails, the costs are<br />

different.!<br />

5. Do not test yourself. Yes, you heard me all right. A code should be tested not by<br />

yourself because you are obviously bias and prejudiced, but by another person who<br />

is definitely more bias and prejudiced (against you). In fact the same company<br />

shouldn’t be testing code done from within the company. It should be carried out by<br />

another third party company. Best still, if that company is a specialised one focussed<br />

only on testing. And out of the country.!<br />

So please, now, answer this question. Would you ever, ever, even think about, letting<br />

your software be used in your business or factory, without even having someone like me<br />

testing it? !<br />

!<br />

!<br />

Professore Dr. Jesus Zavala Ruiz, who works on Open Source<br />

Software Self-Organisation Theory, here in the Chapingo<br />

Autonomous University of Mexico, is obviously highly impressed<br />

when I showed him my testing engine and the certificate above. !<br />

My 15 year old son, on the other hand is not. Obviously he is<br />

extremely jealous because he does not possess such certification<br />

before. I have taken him out of school to follow me around the world<br />

so that he can never have the chance to possess any.!<br />

!<br />

Page<br />

7 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Best Open Source Application!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Speaking about putting on a badge, on September 16, Infoworld, the famous IT media<br />

online magazine, announced <strong>iDempiere</strong> as the Best Open Source Application for, I<br />

quote, !<br />

“Small and midsize companies have great choices in Odoo and<br />

xTuple. Larger manufacturing and distribution companies will need<br />

something more. For them, there’s <strong>iDempiere</strong> -- a well maintained<br />

offshoot of ADempiere with OSGi modularity.”<br />

<strong>iDempiere</strong>, is now declared, by an external independent source, without any commercial<br />

solicitation on our part, to be an outstanding high end ERP application, above Odoo and<br />

xTuple and within our heavyweight turf, soundly beating Openbravo, ADempiere and<br />

Compiere. Considering that the others are more heavily funded, with corporate offices,<br />

media campaigns, paid mercenaries and semi closed sources due to their so called well<br />

thought out business models.!<br />

In <strong>iDempiere</strong> we have none of the above and yet we beat them. We cannot close down<br />

as there is no borrowed venture capital fund to repay and no one on the payroll to be<br />

fired. There is no President CEO to run off with the loot. No head quarters to be bombed.<br />

Page<br />

8 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Importance of Testing!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

The screenshot below paints all the words needed to explain the importance of testing. It<br />

is an output at the end of clicking on the Suite play button of an open source testing tool<br />

called <strong>FitNesse</strong> that is setup for <strong>iDempiere</strong>, a free ERP software. The coloured shaded<br />

areas showing what went right or not, coupled with the time it takes to run each test in<br />

sequence automatically. The suite comprised of many tests, each performing very<br />

detailed step-by-step operation that will take a human hours to carry out and without<br />

human error. This test suite took 22.46 seconds to complete, beyond any human<br />

competition.!<br />

Yet hardly any implementors, developers and users I know involved in this complex open<br />

source ERP software project actually use tools such as this to conduct testing after<br />

every change of code or before any deployment of a copy of the system over to a live<br />

production instance. !<br />

Some of my personal contacts in the project are also guilty and have suffered badly from<br />

non testing live deployment. Of course today whenever i talked to them they nod their<br />

heads in agreement but old habits die hard. It is better to stop all other work and go test,<br />

test, test.!<br />

Tests do not lie. They are computed out by dumb machines no doubt but they do not<br />

deviate from what they are programmed to do. And they do it at lightning speeds. It<br />

actually saves money, and disaster such as happened in http://red1.org/BlackPaper.pdf.!<br />

Page<br />

9 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Perhaps this image I chose from the hundreds of graphs and statistics in the Web best<br />

scare the wit out of some of you as to what can happen before it happens.!<br />

Also there is a wrong way to test which is to test what you do by yourself. You would not<br />

want to prove yourself wrong most of the time. Testing should also not be done within<br />

the same team or the same company. It is best done by an external and professional<br />

company or body that is measured by the number of bugs they find in your software. I<br />

know because i learned it while getting CTFL (Certified Testing Foundation Level)<br />

training and passing the exams a number of years ago.!<br />

Of course, having a global open source community grants us free testing all round the<br />

globe and round the clock. But testing costs 5 times more than developing, according to<br />

Microsoft closed door payroll of such personnel. In Adobe, they hire 20 testers to each<br />

developer. Testing is a very expensive and extensive non stop activity. Relegating testing<br />

to tools such as <strong>FitNesse</strong> and later incorporate it into the Jenkins CI suite is the best way<br />

to take testing out of one’s focus and blind spot into a strict disciplined approach that can<br />

guarantee better efficiency as later we shall demonstrate.!<br />

In this paper, I shall go through each test, to look under the hood at its source code so<br />

you can understand more easily and modify or improve the code to share with the<br />

community. This is in accordance with the FLOSS character of this project. Others who<br />

do not understand or able to read code might want to take their leave. It guarantees my<br />

job safety.!<br />

Reference online guide http://wiki.idempiere.org/en/Fitnesse.HowTo !<br />

Reference online test script guide http://wiki.idempiere.org/en/Fitnesse.FixtureReference !<br />

My modifications and test scripts - https://sourceforge.net/projects/red1/files/Testing/ <br />

Page<br />

10 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Features!<br />

The <strong>FitNesse</strong> plugins, are yet another set of amazing work from Carlos Ruiz,<br />

GlobalQSS, of Colombia, under sponsorship of TrekGlobal, USA. The two plugins are<br />

built into the <strong>iDempiere</strong> stack and can be run right away in an <strong>iDempiere</strong> instance with<br />

minimal tinkling. Been OSGi plugins, they can be installed, started, stopped without<br />

impacting the running instance. With the latest modifications introduced by me, they will<br />

not affect the database even, as at the end of each test, the workload is not committed.<br />

Thus the tests can be run over and over again and with testing data changes for end<br />

users to see the effect of a variety of tests on to their systems, and able to quickly<br />

analyse them before deployment to production instance. Values of test data and<br />

parameters and even target tables or processes can be easily changed by lay users with<br />

minimal technical or coding know-how.!<br />

Page<br />

11 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

As seen above the page uses Wikimedia style, thus allowing users who are familiar to<br />

edit the contents of the page. They can change the name of the @parameter@, @SQL<br />

script, *Table* name, operations such as Read Record, Create Record, Delete Record,<br />

Set Variable, Set Doc Action, Assert Record or Variable, and determine what the input<br />

and output should be. The wiki style also allow remarks and guidance to be put onto the<br />

page for readability.!<br />

What is fantastic about Carlos Ruiz work is that the plugin performs all ERP specific<br />

processes and procedures in exact context required in the code. All that users need to<br />

do is just to define what they want in wiki text form without any extra testing Java code to<br />

be written. You can now access any table model in the database, execute any server<br />

process from the Java code, and modify any document in the supply chain, by simply<br />

typing inside the wiki and press Test or Suite. This is as English language Drools as it<br />

can get.!<br />

Different operational text blocks can be put into a single page if desired as a single test<br />

run. The blocks can be shifted around as one moves text around a document. Each<br />

page can be children of a suite for a single chain of execution.!<br />

My Roll Back Improvement!<br />

I submitted such an improvement here. http://idempiere.atlassian.net/browse/IDEMPIERE-2860.<br />

As can be seen from my Skype with the big man, he seems to like it. !<br />

This improvement is important because without it, any tests will be committed to the database<br />

and will affect the data test plans which is already fixed and assume a clean database. It will<br />

require constant restoring of the database back to run the test set again. The incorporation of<br />

trxName handling in most of the code parsing also opens up future possibilities. I also<br />

incorporate a Commit tag in case the tester really wants the test to be in database for further<br />

checking. Pick up the plugin to replace in <strong>iDempiere</strong>-server here: Plugin:_<strong>FitNesse</strong>_RollBack!<br />

Page<br />

12 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Create Record Auto!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

I also contributed a fixture code that<br />

allows creation of new records to be<br />

faster without specifying the fields and its<br />

values. Just by a blank line will allow the<br />

code to fetch the right data types and<br />

populate as many fields possible in the<br />

table. The user can still specify own<br />

values underneath the blank line. An<br />

example is given here of creating a Sales<br />

Order. The other fixture code remains the<br />

same. The result is shown below it.!<br />

An example of mixing lines into it to make<br />

it a Purchase Order is given here in raw<br />

text:!<br />

|*Table* ! |! C_Order! |!<br />

|! |! |!<br />

|c_doctypetarget_id | @Ref= c_doctype<br />

[Name='Purchase Order’].c_doctype_id !|!<br />

| C_Currency_ID | ! 100 |!<br />

| isSOTRX | ! N ! |!<br />

|*Save* | |<br />

Page<br />

13 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Handling Info Window!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

I made yet another useful and very important fixture method to test InfoWindow that has<br />

processes attached to them to process the record set it displays. By specifying Read Info<br />

Window, the code will take the specified Info Window, extract its SQL sequence, and read its<br />

database result to pass to the next fixture ‘Run Process’ to execute. This is very useful because<br />

a growing number of <strong>iDempiere</strong> data processing constructions are using the InfoWindow<br />

approach. Below is an example of it working while testing the Forecast module.!<br />

This script display at its first box will access the Info Window named ‘Generate Sales Forecast’ in<br />

AD_InfoWindow table, and access its AD_InfoProcess via the next box to execute<br />

GenerateBudget2SalesForecast which reads off the first box result. Below is the result.!<br />

The above successful read is evident as it returns the process full response dictated by the<br />

process code. This addition does not change Run Process script and is backward compatible.!<br />

The only bug I had was that the PInstance ID does not persist and so i made an incremental<br />

hack to track it back. For most purposes it should work and even allow to specify secondary<br />

process of the InfoWindow. The Read Info Window only extracts the first record and thus the<br />

process will always handle one line of resultset. This is sufficient to test that they work in<br />

accordance. The raw script is given under the Forecast Module later.!<br />

!<br />

Page<br />

14 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Developer User Guide!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

As the online wiki guide should be sufficient, this guide intends to really go into the exact<br />

testing scripts or Fixture stories as they are called by the <strong>FitNesse</strong> authors and trace the<br />

exact Java code snippets that handle them. Much can be learned and more time saved.!<br />

!<br />

Developer Setup!<br />

I am using my developer setup environment so that during <strong>FitNesse</strong> testing, a debug mode can<br />

be used to check the actual code parsing under the hood. Contributed original work can be read<br />

directly online from http://wiki.idempiere.org/en/NF001_Fitnesse_Integration wiki by Heng Sin.!<br />

Following the tutorial given and as an <strong>iDempiere</strong> developer, I can completely setup inside my<br />

Eclipse IDE environment. In a materialised <strong>iDempiere</strong> source-code for the IDE, you should be<br />

able find the two <strong>FitNesse</strong> plugins already present within the stack. During debugging usually<br />

they are set in lazy mode and need to be started in the OSGi console.!<br />

After starting they should be in active mode. Otherwise <strong>FitNesse</strong> will not connect to the ERP.<br />

Once that is OK, run the <strong>FitNesse</strong> engine externally by going to the ‘fitnesse’ folder location in<br />

the source code and execute java -jar fitness.jar -p 8089 so it can be accessed at that port 8089.<br />

Pressing the Suite button on the top left should give you the first screen-shot in this paper. From<br />

here, my tutorial shall assist with full illustration from this point onwards.!<br />

!<br />

Create A New Test!<br />

Let’s try by using the Create<br />

Record to add any record that we<br />

want. Let us make a new User<br />

record. Further below is what i<br />

prepared in raw text mode. It is<br />

clear that we need to know the<br />

exact Foreign Keys to lookup.<br />

You can access the GardenWorld<br />

sample database quickly by going<br />

to http://red1.org/DocBook and<br />

search for any window to get to<br />

its tabs’ table data. !<br />

First, we have to add a new test<br />

to the suite. Click on the Add<br />

Child in the <strong>FitNesse</strong> FrontPage<br />

or the <strong>iDempiere</strong>Suite within.!<br />

For this simple testing, I choose to add within the <strong>iDempiere</strong>Suite. Later, for Forecast Module<br />

chapter has its own suite all nicely arranged out.!<br />

Page<br />

15 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

!<br />

Set it to Test type. Put a Name as above. Do not disturb the Content value. Click on Add.!<br />

Page<br />

16 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Now you can click on that new link ‘Create Any Record’ to enter the wiki text. A simple way is to<br />

copy and paste from the ‘Create Business Partner’ page below it. As advised, I use my DocBook<br />

to find out the field names, and arbitrary<br />

values to think about putting them in.!<br />

So here is my starting page in its wiki<br />

test. Let’s give it a go.!<br />

Note that i added Roll Back so that the<br />

transaction is properly closed and any<br />

creation is not finally saved into the<br />

database, messing it up.!<br />

Once I clicked save, below is how it<br />

looks. I then can try it by pressing test.<br />

The bottom green coloured box at<br />

*Save* confirms that it works. But we like<br />

to see if it really does. We can use the<br />

Read Record to check. Let’s see what<br />

updated value a user record does.!<br />

Note also that we can have a *Commit*<br />

in Roll Back in case the new record is needed.!<br />

Here, we have successfully made a<br />

new wiki test page in the <strong>iDempiere</strong><br />

<strong>FitNesse</strong> test engine. And the test<br />

works! Let’s add a read script to see if<br />

the test also can do so. But first when<br />

I checked via <strong>iDempiere</strong> login, I can<br />

confirm that this record was not<br />

created. !<br />

I paste the text here so that you can<br />

copy and paste back to your wiki to<br />

try.!<br />

!include -c TestLoginGardenAdmin!<br />

!|Create Record|!<br />

|*Table* |AD_User |!<br />

|NAME |@random_string(Red1,6)|!<br />

|Value |@random_number(,,8)|!<br />

|Email |red1@red1.org|!<br />

|Password|@random_string(aaa,6)|!<br />

|Phone|@random_number(,,8)|!<br />

|*Save* | |!<br />

!|Roll Back|!<br />

|*RollBack*|TRUE|!<br />

Page<br />

17 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

!<br />

Roll Back Or Commit Option !<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

I then test with the Roll Back option of Commit.!<br />

Then in the <strong>iDempiere</strong> browser, I could see that a new record similar to this test is created. !<br />

The test works with the commit action to quickly create what I wanted.<br />

Page<br />

18 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Read Record!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Here we try to read the virtually created AD_User even though not committed to prove that the<br />

testing does persist during runtime only.!<br />

Just look at its blistering speed of 0.026 second! Here we see that it does return the same values<br />

and so this test is a resounding success. Note that we get the same ID by<br />

@AD_User.AD_User_ID@ that fetches from same memory during testing. There is also no trace<br />

of the record during my own normal login to check, as its not committed. However this also<br />

discover a hole in vanilla <strong>iDempiere</strong>. We can get to the password! What a catch! Anyway, for<br />

now you can save your fixture story.!<br />

!<br />

Page<br />

19 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Location of<br />

Fixture Story!<br />

Whenever you press save,<br />

your fixture story is saved in<br />

the location of <strong>FitNesse</strong><br />

folder under <strong>FitNesse</strong>Root,<br />

exactly where you are to<br />

replace with my similar<br />

named folder, zipped at<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

http://sourceforge.net/projects/red1/files/Testing/ !<br />

!<br />

Location of Source-Code!<br />

You might want to know later during the sample suite extravaganza, where all the code comes<br />

from.!<br />

The java class names are obvious and refer to the wiki text block titles. Thus to create a new title<br />

is simply to have a corresponding Java class with the same name with its spaces removed.<br />

Notice how I did with my new class, RollBack.java.!<br />

Page<br />

20 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Ready-Made Test Suite!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

We shall now go through important tests within the suite created by Carlos Ruiz. His<br />

work is really amazing that he provides more than sufficient examples to allow me to<br />

pick it up rather quickly. !<br />

!<br />

Quick Test!<br />

The purpose of the quick test is to make sure your <strong>FitNesse</strong> engine is working fine besides<br />

checking if your database is alive and responding. It also demonstrate the use of Set Variable<br />

and Read Record.!<br />

You can find the two source code Java classes that handle them namely SetVariable.java and<br />

ReadRecord.java. The @InventoryLevelBefore@ are arbitrary variables that you set for runtime<br />

reference later in the wiki script. They are not reserved or hard-coded. This is a powerful<br />

mechanism that Carlos Ruiz introduced to allow capturing or passing of values during the tests.!<br />

!<br />

!<br />

!<br />

Page<br />

21 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Test Cash POS Order!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

This test page is an example of an<br />

elaborate long test with many Java<br />

classes used to perform many tasks.<br />

First it sets variables for later use. It is<br />

testing for a sales of qty 2 and checking<br />

later if the inventory is correctly reflecting<br />

that from the POS order operation. In the<br />

next read record test, it is checking the<br />

Business Partner’s details. !<br />

Next is the creation of the master detail<br />

record structure of a Sales Order. Note<br />

how the DoctType setting or POS Order<br />

is done. !<br />

Also note how the first master table<br />

C_Order’s key ID is passed to the sub<br />

detail C_OrderLine_ID as its parent<br />

foreign key ID. The variable used is<br />

@c_order_id. c_order_id@!<br />

!<br />

Page<br />

22 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Run Process!<br />

The next testing task in the page is Run<br />

Process which will Complete the POS Sales<br />

Order. See how simple it is. The<br />

*ProcessValue* corresponds to the name of the<br />

process record. !<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

The other variables with paired values are the<br />

parameters to pass to the server process.<br />

Finally a *Run* sends it away.!<br />

You can now imagine any sort of process to test with this simple framework template.!<br />

!<br />

Assert Record!<br />

This test checks if the expected result placed in the<br />

box is returned correctly during runtime testing. Here<br />

the new order is supposed to give a grand total of<br />

67.50. Let’s compare the results below.!<br />

The earlier green boxes are bypassed as we have<br />

gone through such. Here we see the Run Process is<br />

successful with feedback of the model data set<br />

returned. So is the Assert Record feedback similar<br />

value to the expected setting. Thus its all green and deemed correct.!<br />

Page<br />

23 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Assert Variable!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

This last test now takes the earlier variable and assert it to the SQL that is extracting the total<br />

QtyOnHand from M_Storage table.!<br />

Here is the result shown in the page test. However before this, the assertion was comparing<br />

string value and thus 28 is not equal to 28.0. I gave a patch to solve it here:!<br />

https://idempiere.atlassian.net/browse/IDEMPIERE-2859 !<br />

However Carlos Ruiz has remarked that indeed it is to test string value, and so I added a new<br />

fixture code ‘AssertString’ strictly for strings, and this AssertVariable be for both alphabetic and<br />

numerical values if they can be deduced as such during the assertion.!<br />

Next the rest of the page is testing the existence of spawned records such as Invoice, Payment<br />

and Shipment. This is all easily done by reading and asserting the associated records. This test<br />

page is a very informative and educational reference for any other testing to be quickly setup as<br />

most of the operations are covered by it.!<br />

!<br />

!<br />

Page<br />

24 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Forecasting!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Purchasing Forecast is an approach to shorten the supply chain functionality in the ERP<br />

bypassing inventory replenishment control and manual requisition. !<br />

Purchase forecasts are generated during Sales Forecast and even Sales Order when<br />

the plugin is active. You will get this line in the log console: !<br />

INFO: .. IS NOW INITIALIZED!<br />

The purchase forecasts are then processed into actual purchase orders. !<br />

Sales Forecast blanks can also come out from Budget Plan Details that are sales target<br />

type for the user to fill up details (if the Budget Plan is abstract).!<br />

The Forecasting module is a standalone plugin with no core table change and thus pose<br />

no impact or conflict to other.!<br />

The illustration above shows how the coloured area stands for the whole plugin, and the<br />

cutout is part of the underlying core that it is not trespassing on. The Budget Plan<br />

module, together with the Sales Forecast, Sales Orders and Purchase Orders remain<br />

intact and outside the plugin. The Budget plugin is also upgraded to include the<br />

contribution from Deepak Pansheriya - http://logilite.com/budget-journal-enhanced-budget-module/!<br />

If anything changes in the plugin, it does not break those outside. If anything outside<br />

changes it may break the plugin but that is easier to solve than the other way round. The<br />

plugin is small, the core is huge. Perhaps this should be my 4th mantra. The core is<br />

huge, you have to plugin.<br />

Page<br />

25 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Reusing Forecast Model!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

The Purchasing Forecast is reusing the Sales Forecast model tables of M_Forecast and<br />

M_ForecastLine with an additional M_ForecastProcess to handle the purchasing associated<br />

operations without impacting the present forecast model. The whole model is also presented in a<br />

new window away from the Libero Manufacturing module where it is originally maintained.!<br />

As seen above, the Purchase detail will reuse the Line tab, but the Process tab at the bottom will<br />

indicate if it is a purchasing forecast. A blank process detail means it is not a PO Forecast but<br />

just the usual Sales Forecast. If there is a detail as it is in this case, then it is a PO Forecast. You<br />

can go to the main tab ‘Forecast’ to review its header information.!<br />

Under the line tab, is already stating the Product, Quantity, Period and Date Promised. In the<br />

Forecast Process tab, will store the Purchased LeadTime which is partially hidden to the right<br />

side of the row.!<br />

The Forecast Process tab also keeps track of the origin of the Purchase forecast such as<br />

whether it is from one of these: Sales Order and OrderLine, or Sales Forecast and ForecastLine.<br />

In this case it is from a Sales Forecast. (The Forecast column is quite redundant as it is a repeat<br />

of the main tab. It can thus be easily hidden using the Tab Editor. I will remove it in the next<br />

upload commit.)!<br />

The Forecast Process tab also keeps track if this PO Forecast has been processed, together<br />

with its generated Purchase OrderLine reference ID. !<br />

!<br />

Page<br />

26 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Forecast Menu Structure!<br />

You can find this new Forecast Model under the Forecast<br />

Orders menu (after packing in ForecastWindow.zip or<br />

installing the plugin - org.purchasing.forecast.jar). Here<br />

on the right, is the menu below alongside the Budget<br />

Sales Planning. Note the last item in it, Generate Sales<br />

Forecast is associated with Forecasting and so will only<br />

work if the Purchasing Forecast plugin is also active. If<br />

the Generate Sales Forecast is not used, it is of no<br />

requirement to either modules to be present at the same<br />

time.!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Purchasing Schedule is an Info Window that reviews the<br />

Purchasing ForecastLines and allow its selection to be<br />

processed into Purchase Orders.!<br />

The first item, Generate Purchase Forecast, creates PO<br />

Forecasts from Sales Forecasts. The 2nd item, Generate<br />

Purchase Orders creates POs from PO Forecasts. This is<br />

basically the main purpose of this module. Sales<br />

Forecasts to PO Forecasts to POs.!<br />

The POs are also consolidated according to similar<br />

vendors supplying those product items defined in the forecasts.!<br />

Below, next page is the Generate Sales Forecast Info Window. It goes through the Budget Plan<br />

Detail lines to sniff out those that are sales targets and display them for further action. That<br />

means those that have isSOTrx field set to ‘Y’ and the Accounting Element field empty. Those<br />

budget details, you have to create them and ensure that they possess Product, Qty, and Period<br />

values to be flagged for display in the InfoWindow.!<br />

Once they are selected, they can be processed into Sales Forecast lines under a single forecast<br />

header.!<br />

Note that in the Budget module, there is a Budget Configurator that you have to setup. You can<br />

refer to the Budget.pdf at http://sourceforge.net/projects/red1/files/p2/Budget/!<br />

Note also the Import Budget Plan. You can run the File Import Loader and load up<br />

BudgetTestImport.csv (same location above). Then run the Import Budget Plan. But you may still<br />

need to set a Sales Forecast candidate by making a new detail without Accounting Element and<br />

proper values as stated in the first test below for Purchasing Forecast module.<br />

Page<br />

27 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Sales Plan Info Window!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

The Budget Module is linked to this Forecast Module by allowing a subset of Budget Plan Details<br />

that are for Sales targets to be converted to Sales Forecasts. Below is the Budget Plan Detail<br />

Rules tab that contains sales target because the Accounting fields is blank and thus not for GL.!<br />

In the Generate Sales Forecast (InfoWindow) it can display this record for selection to process<br />

into a Sales Forecast:!<br />

Now it be nice for the <strong>FitNesse</strong> test to read this InfoWindow, its content, and activate that<br />

process button. In fact with my added improvement it does. We can now Read Info Window and<br />

pass to the prevalent Run Process to do so.!<br />

Page<br />

28 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Testing Budget to Sales Forecast !<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Below is the raw script to make that happen. It is placed side by side with the wiki display version<br />

of the <strong>FitNesse</strong> interface. Note the pre-requisite information stated in the wiki header.!<br />

!include -c TestLoginGardenAdmin!<br />

!|Read Info Window| !<br />

|*InfoWindow*|Generate Sales Forecast|!<br />

!|Run Process|!<br />

|*ProcessValue*|GenerateBudget2SalesForecast|!<br />

|*Run*||!<br />

!|Roll Back|!<br />

|*RollBack*|TRUE|!<br />

When this test is executed, the resulting<br />

dataset from the Budget Plan line<br />

pertaining to Sales target is processed<br />

and below shows its success.!<br />

The process returns other information<br />

such as whether any of the result has no<br />

qty or no customer or no period (to<br />

gather its date promised). This will aid<br />

the user to go through the Forecast<br />

model window later to put in such<br />

missing details. You can change the<br />

Budget Plan Detail Rules tab data on<br />

the earlier page to see a<br />

different run result. This is<br />

very fast to execute as can<br />

be seen takes less and less<br />

seconds at each run. You<br />

can add another text box to<br />

Read Record of<br />

M_ForecastLine to check<br />

any of the actual results.<br />

Again when run, should just<br />

take some extra<br />

milliseconds.!<br />

Note that Budget Plan Sales<br />

Target could be a high level<br />

plan or general target which<br />

requires more exact planning at the forecast stage. From this Sales forecast, it can then be<br />

processed as shown before this to Purchasing forecast and so on till Purchase Orders. Thus this<br />

is a complete supply chain link from budgetary planning until actual purchasing decision.<br />

Page<br />

29 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Purchasing Forecast Info Window!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Below is the Purchasing Schedule Info Window (labeled as Purchasing Forecast) with its<br />

selection criteria panel to filter further the row set data. (The contents are converted Sales<br />

Forecasts and so they appear as Purchase ForecastLines. Your fresh DB should not show this<br />

yet.)!<br />

Been an Info Window (created by Heng Sin and then improved by myself, Anthony Soosah, Hiep<br />

LeQ and others) this can be easily modified or configured under the System Application<br />

Dictionary (AD) as to its selection panel and column display. It also allows a selection of those<br />

rows to be processed by the Generate Purchase Order button.!<br />

Now we see again another test fixture that does the above to get the Purchase Forecast<br />

InfoWindow and Generate Purchase Order. Execution and results are shown on the next page.!<br />

!<br />

!<br />

Page<br />

30 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Testing PO Forecast to PO!<br />

!include -c TestLoginGardenAdmin!<br />

!<br />

!|Read Info Window| !<br />

|*InfoWindow*|Purchasing Forecast|!<br />

!<br />

!|Run Process|!<br />

|*ProcessValue*|InfoForecastGeneratePO|!<br />

|*Run*||!<br />

!<br />

!|Roll Back|!<br />

|*RollBack*|TRUE|!<br />

!<br />

!<br />

!<br />

!<br />

The above is the raw story<br />

script and the right is the saved<br />

wiki from it. A note to testers<br />

how to determine the Process<br />

value, is by looking at the<br />

InfoWindow’s process tab and<br />

copy paste the Search Key<br />

value there. As seen above, it<br />

is InfoForecastGeneratePO.!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

!<br />

!<br />

When the test is started, on the<br />

right is the green result.<br />

Page<br />

31 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Testing Sales Order<br />

to Forecast!<br />

Next we go to other ways of<br />

creating Sales Forecasts. There<br />

is a Sales Order way which is<br />

due to the plugin Model or Event<br />

Validator that acts when you<br />

complete it. Here is the test in<br />

full.!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

!<br />

First a Sales Order is made<br />

u p o f C _ O r d e r a n d<br />

C_OrderLine, so these two<br />

tables are populated and<br />

processed respectively.!<br />

!<br />

!<br />

The C_OrderLine taking the<br />

parent ID from the table above,<br />

C _ O r d e r v i a t h e<br />

@C_Order.C_Order_ID@ variable.!<br />

The Run Process completes the<br />

order and Assert Record finds out<br />

that indeed M_ForecastProcess is<br />

created proving the PO<br />

ForecastLine exists.<br />

Page<br />

32 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Testing Forecast<br />

Model Processing!<br />

Then there is a manual way<br />

through the Forecast Window. Here<br />

is a fixture code to create a Sales<br />

Forecast header and line and then<br />

process all in the DB. !<br />

There is an additional script to test<br />

the Lead Time calculation which is<br />

basically adding backwards number<br />

of days set in the Product PO<br />

(Vendor) DeliveryTimePromised<br />

field, to the DatePromised in the<br />

Forecast.!<br />

Here the Vendor for a Product is<br />

updated by 2 days.!<br />

The Product PO is then read<br />

back to confirm the setting.!<br />

Here my new Create Record Auto<br />

fixture is used to make it faster to<br />

define new table tests with a blank line<br />

trigger. !<br />

Note how simpler it is. Each table<br />

definition has a blank line. The detail<br />

line has an additional line to define the<br />

p a r e n t I D . T h u s m i x i n g w i t h<br />

conventional statements as in Create<br />

Record fixture is allowed and working<br />

as can be seen with M_ForecastLine.!<br />

Also note that the RollBack feature<br />

closes the active transaction thus<br />

freeing connection to avoid memory<br />

leak and slow performance when more<br />

tests are loaded into the testing suite.!<br />

From the initial Generate POForecast<br />

to PO, it is easy to add one more test,<br />

another Run Process to convert the<br />

runtime generated PO Forecasts to<br />

Page<br />

33 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Purchase Orders. Then reading back the record allow the PO Forecast to be tracked<br />

back accurately via its ID for the final Purchase OrderLine to show what is the date<br />

Ordered and Promised as required.!<br />

Below is the successful test results. !<br />

Results remarks continued on the next page. Indeed, this test is very versatile, easily<br />

setup with no code meddling such as the case with JUnit testing. This saves a lot of time<br />

and I feel smooth sailing when I just add that last small process snip.!<br />

In fact upon running the test, I detected two errors in my code of not setting the<br />

mandatory data well. After fixing that in my modules, the test confirms back everything is<br />

in order.!<br />

!<br />

Page<br />

34 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

The table is successfully<br />

updated for the Product ID<br />

= 138 (Hoe 4ft) as shown<br />

and then read back to<br />

confirm the 2 days lead<br />

time setting. !<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

You can change that<br />

Delivery Time Promised<br />

and view the results at the<br />

bottom to confirm that the<br />

PO created has its Date<br />

Ordered set backwards<br />

accordingly.!<br />

Note that the POs are<br />

consolidated to respective<br />

vendors and returned<br />

message of success.!<br />

With that we have covered<br />

the whole module from top<br />

to bottom. Every time there<br />

is a change, just run these<br />

tests on a trial version to<br />

get a quick instant glance if<br />

anything is broken.!<br />

Page<br />

35 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Putting It All Together!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

The power of <strong>FitNesse</strong> is the way it can package a series of tests together into a suite. Thus I<br />

have done that with Forecasting as shown below, marked as ForecastModuleTesting.!<br />

Clicking on the last suite brings you to this page. And you can press the Suite button to run all of<br />

the tests. However you may need to remove the Roll Back in between so that they have time to<br />

breathe. Running each individual one will work though.!<br />

This suite story folder is uploaded into my Sourceforge repository. <br />

Page<br />

36 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

German Localisation !<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

As part of my project work is mainly in Germany with AulerSipel group of companies that<br />

contributed a lot to German Localisation, I am also advising a full set of tests for them to<br />

assist in their migration from <strong>iDempiere</strong> 1.0c to 2.1 or 3.0, where such tests are<br />

paramount to ensure that the ERP application performance remains secure and<br />

consistent afterwards. This test suite is also useful to the German community as a<br />

number of the plugins they developed together with me are of common need to the<br />

community there. These tests are also useful for the world at large as there are plugins<br />

that are of global usefulness.!<br />

<br />

Page<br />

37 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Manufacturing!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Perhaps this is the most painful part that truly needs testing to work all out for. The<br />

Libero Manufacturing module as reviewed few times over about 5 years span by me<br />

personally has discovered some unfinished features and breaking code. It is an<br />

ambitious project trying to cover a huge span of the Manufacturing and Distribution<br />

horizon. It could have been better organised into more distinctively separate modules<br />

and and better interfaces. Another challenge is the lack of real subject matter experts<br />

involving in this project or publishing a good model to follow.!<br />

However previous tests were able to ensure certain parts of it worked according to its<br />

coded intent. My review and upgrading of Libero is still ongoing to make it more<br />

wholesome that involved me going to Denmark to get input from a turbine and truck<br />

body maker. More complete tests are needed as well as regressive testing to ensure<br />

nothing before it has been broken. !<br />

I did a major renaming exercise within the code merely sticking to the Libero project<br />

name and all vendor or developer names are removed as namespaces. Original copy<br />

right and authorship is kept intact attributing to Jorg Janke of Compiere and eEvolution<br />

of Mexico. You can follow this progress in my forum here http://red1.org/adempiere/<br />

viewtopic.php?f=45&t=1775&p=8691#p8691 !<br />

!<br />

(As I am writing this here in Mexico, I am due to meet up with the original creator of<br />

Libero and Forecasting, who has called me up by phone and told me about his latest<br />

forecast enhancement. I shall examine that and see if this model holds up without any<br />

cross impact and where need be I shall adjust and take advantage of any goodies<br />

contained in them.)!<br />

!<br />

!<br />

Page<br />

38 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Warehousing!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

Orignally also under Libero, but this time Muiltimage of Slovakia under Norbert Bede has<br />

done tremendous improvements to it and it is now a big task to document all their work<br />

and setup a good testing engine at the same time.!<br />

!<br />

!<br />

!<br />

Page<br />

39 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Point of Sales!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

The prevalent popular or preferred POS system undergoing continuos integration works<br />

to <strong>iDempiere</strong> is from Openbravo POS fork of Unicenta. !<br />

!<br />

!<br />

!<br />

Page<br />

40 of 41<br />

Copyright (C) 2015 Redhuan D. Oon


iROSES<br />

Mobile Apps!<br />

<strong>iDempiere</strong> <strong>FitNesse</strong><br />

There are quite a number of mobile apps emerging stronger such as SpinSuite Android<br />

and iUIMobile!<br />

<br />

Page<br />

41 of 41<br />

Copyright (C) 2015 Redhuan D. Oon

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!