2 Replies Latest reply on Sep 20, 2012 1:50 PM by Jason Prozora-Plein

    Supplying parameters in a request to run a parameterized request?

    Jason Prozora-Plein Adobe Employee

      Hi all,

       

      I was wondering if there was a way to include the parameters to pass to a parameterized test in a request to run that parameterized test. If a test is parameterized, adding the request returned by Request.method() to the list of requests passed to FlexUnitCore.run() will cause the parameterized test to be run once for each item returned by the parameterized test's [Parameters] method. I don't know of a way to create a request to pass to FlexUnitCore.run() which would run a test once, with specific parameters passed to the test.

       

      For example, here's a simple parameterized test:

       

      package
      {
           import org.flexunit.runners.Parameterized;
      
           [RunWith("org.flexunit.runners.Parameterized")]
           public class SimpleParameterizedTest
           {          
                private var _param:int = 1;
                
                public function SimpleParameterizedTest(param:int)
                {
                     _param = param;
                }
                
                [Parameters]
                public static function getData():Array
                {
                     return [[1], [2], [3]];
                }
                
                [Test]
                public function runTest():void
                {
                     trace(_param);
                }
           }
      }
      

       

      If I run the test with this code:

       

                     var flexUnitCore:FlexUnitCore = new FlexUnitCore();
                     var request:Request = Request.method(SimpleParameterizedTest, "runTest");
                     flexUnitCore.run(request);
      

       

      ... then SimpleParameterizedTest's constructor is called three times, first with 1, then with 2, and finally with 3, and runTest() is called three times. What I would like to do is, e.g., to create a request that would cause the constructor to SimpleParameterizedTest to be called once with a value of 2.

       

      We have a set of large files and real-world files which we use in performance tests - e.g., to time opening, saving, and closing. We have a set of parameterized tests which take these files as inputs: each of the [Parameter] methods for these tests gets the contents of a folder, and returns a list of filenames which match a particular pattern. Our test automation system has a UI which allows a dev or QE to select the set of tests to run, but without modifying the contents of the folders the tests look in, there is not a way for him or her to select a subset of these parameterized tests to run. Similarly, we would like our test automation which executes the performance tests to be able to run a test on a particular file.

       

      If there is not a way to include the parameters in the request, our plan is to modify the [Parameters] method for the test so that the test can ask the test automation system for the parameters and (e.g.) return a list generated by the contents of a folder if the test automation system does not have parameters.