Skip navigation
Currently Being Moderated

FlexUnit 0.9 to FlexUnit 4 question

Aug 10, 2010 7:26 AM

Hi me again with a question.

 

Our Flex applications have a back-end to retrieve and set information from/to. This back-end server requires a login (and logout when done). Now every bit of functionality that is tested via this back-end has seperate cases based on groups of functionality (there are about 150 - 200 different calls grouped in about 20 test cases).

 

In FlexUnit 0.9 the suite was setup as follows:

 

 

public class EIBTestSuite extends TestSuite
     {
          public function EIBTestSuite()
          {
               // Verify that the servers are online
               this.addTest(new EibCase("VerifyEuroportTest"));
               this.addTest(new EibCase("VerifyServiceTest"));
 
               
               // Login
               this.addTest(new UserCase("LoginTest"));
 
               
               // Payment
               this.addTest(new PaymentCase("paymentStart"));
               this.addTest(new PaymentCase("paymentEntry"));
               this.addTest(new PaymentCase("removePaymentEntry"));
               this.addTest(new PaymentCase("loadStandingPayments"));
 
               
               // Other cases
 
               
               // Logoff
               this.addTest(new UserCase("LogoutTest"));
          }
     
     }

 

 

As you can see the Login and Logout test are in the same case but are called not directly after eachother. This way we don't need to do the login / logout calls for every case we have.

 

Now I'm trying to convert our tests to FlexUnit 4 but I have a problem with converting the above code to FlexUnit 4. Because when I would change the above code to the following all cases after the UserCase would fail because there is no user logged in.

 

 

[Suite]
     [RunWith("org.flexunit.runners.Suite")]
     public class EIBTestSuite
     {
          public var eibCase:EibCase;
          public var userCase:UserCase;
          public var paymentCase:PaymentCase;
          // Other cases
     }

 

 

 

What we could do is add the login and logout calls to each seperate case and ensure the order in which the tests are executed. But first of all this is a lot of repetition for the same piece of code and second if the login procedure would ever change it would have to be changed in all the cases. Neither is desirable.

 

Is there a best-practices way for changing the described situation to FlexUnit 4?

 

Thanks for the help,

Rick Veenstra

 
Replies
  • Currently Being Moderated
    Aug 10, 2010 9:55 AM   in reply to Wubzorz

    You should order your tests

    [Test(order=2)]

    [Test(order=3)]

    etc.

    more info here http://docs.flexunit.org/index.php?title=Order

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 11, 2010 6:03 AM   in reply to Wubzorz

    I would make a test suite that contains all of your tests case. Test suites can also contain other suites, so this should be very flexible regardless of the number/types/levels of test hierarchy.

     

    You should then be able to make two *static* functions of the top-level suite. One will be for logging in. One will be for logging out. Mark the login one with [BeforeClass] and the logout with [AfterClass]. These functions need to be static because they quite literally run before the suite constructor and potentially after garbage collection of the suite.

     

    I personally would prefer to login and logout before and after each test as you know there is no state or other session information that has been corrupted, but this method should work for what you are asking.

     

    Mike

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points