Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2008

Tip: Looking for answers? Try searching our database.

help testing state

Thread view: 
mike - 13 May 2008 19:38 GMT
Hi,

We have the following method that we need to test ( see code snippet).

I know about junit ( using 4 here) and Jmock, but all hints are
welcome.
How can I write a test that excerises createNewHome

public void createNewHome(String address){

Address newAddress = aHome.create();

switch(state) {
            case INITIAL:
              //Do stuff
              //Set state to INVITE
            case INVITE:
                //Do something else
                //Set state to TERMINATE
            case TERMINATE:
                //Do something other
                //Set state to INTIAL
                break;
            default:
                System.out.println("Not a valid state");
        }
//More code .......

}
Daniel Pitts - 14 May 2008 00:31 GMT
> Hi,
>
[quoted text clipped - 25 lines]
>
> }
Generally, you don't test state, but behavior.
you would start from a known state, simulate stimuli and then assert the
correct response to the stimuli.

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Roedy Green - 14 May 2008 06:38 GMT
On Tue, 13 May 2008 11:38:06 -0700 (PDT), mike
<mikaelpetterson@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>switch(state) {
>             case INITIAL:
[quoted text clipped - 11 lines]
>         }
> //More code .......

see http://mindprod.com/jgloss/finitestate.html
For some ideas on how to implement state machines.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.