1 Reply Latest reply on Apr 28, 2010 7:22 PM by mlabriola

    Injecting properties to test cases


      Using FlexUnit 4, what is the appropriate way to run the same tests as a unit test with a mock service implementation, and again as an integration test  or BVT with the actual remote service.


      Specifically, if my testcase class has a property "service:IMyService" I would like to run it once with a service implementation injected (perhaps from a suite class?), and once with a mock implementation. But it appears the suite classes do not actually instantiate the test case, they just declare them.

        • 1. Re: Injecting properties to test cases
          mlabriola Level 4

          Two answers for you:




          You could put all of the code of in a test case and create a protected variable for the service of type IMyService. Then you could create two subclasses of this test which each just set that property, one which instantiates the real service and one which does the mock. Then run the subclasses as opposed to the base class.


          Very soon:

          This has been on our list for a while. We have a new way to support injection into classes as well as parameterized testing which will be making its appearance in the project very soon. Expect to see this available in some form of beta within the next week or two.