Skip navigation
BeeWrog
Currently Being Moderated

Strange behaviour when running parameterized test

Oct 23, 2011 11:20 PM

Hello,

I am using Flex 4.5 and FlexUnit 4.1 inside of the Flashdevelop IDE and I am experiencing some very strange behaviour.

 

If I have 5 parameters to my test the test runs fine. When I add a sixth parameter of the type Array, I get the following error:

"TypeError: Error #1009: Cannot access a property or method of a null object reference."

Please see below for my example code.

 

The following parameterized test case runs without a problem:

 

package {

    import org.flexunit.runners.Parameterized;

 

 

    [RunWith('org.flexunit.runners.Parameterized')]

    public class ParameterizedTest {

        [Parameters]

        public static var testData:Array = [

            [1,1,new Array(),1,1]

        ];

 

 

        public function ParameterizedTest(

            param1:uint,

            param2:uint,

            param3:Array,

            param4:uint,

            param5:uint

        ):void {

        }

 

 

        [Test]

        public function testOne():void {

            // Test to go here.

        }

    }

}

 

When I add an Array as the sixth parameter :

 

package {

    import org.flexunit.runners.Parameterized;

   

   

    [RunWith('org.flexunit.runners.Parameterized')]

    public class ParameterizedTest {

        [Parameters]

        public static var testData:Array = [

            [1,1,new Array(),1,1,new Array()]

        ];

       

       

        public function ParameterizedTest(

            param1:uint,

            param2:uint,

            param3:Array,

            param4:uint,

            param5:uint,

            param6:Array

        ):void {

        }

       

       

        [Test]

        public function testOne():void {

            // Test to go here.

        }

    }

}

 

I get this error :

 

com.berog.proj_drum_machine.tests.matrix_test_suite.test_cases::Matrix ConstructorTest.testOne (1,1,,1,1,) .

TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at flex.lang.reflect::Constructor/newInstanceApply()[E:\hudson\jobs\Flex Unit4-Flex4.1\workspace\FlexUnit4\src\flex\lang\reflect\Constructor.as :253]

    at TestClassRunnerForParameters/createTest()[E:\hudson\jobs\FlexUnit4-Fl ex4.1\workspace\FlexUnit4\src\org\flexunit\runners\Parameterized.as:45 5]

    at org.flexunit.runners::BlockFlexUnit4ClassRunner/methodBlock()[E:\huds on\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runners \BlockFlexUnit4ClassRunner.as:314]

    at org.flexunit.runners::BlockFlexUnit4ClassRunner/runChild()[E:\hudson\ jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runners\Bl ockFlexUnit4ClassRunner.as:152]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runners::Parameterized/runChild()[E:\hudson\jobs\FlexUni t4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runners\Parameterized. as:273]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runners::Suite/runChild()[E:\hudson\jobs\FlexUnit4-Flex4 .1\workspace\FlexUnit4\src\org\flexunit\runners\Suite.as:151]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runners::Suite/runChild()[E:\hudson\jobs\FlexUnit4-Flex4 .1\workspace\FlexUnit4\src\org\flexunit\runners\Suite.as:151]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runner::FlexUnitCore/beginRunnerExecution()[E:\hudson\jo bs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexU nitCore.as:348]

    at org.flexunit.runner::FlexUnitCore/runRunner()[E:\hudson\jobs\FlexUnit 4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as: 307]

    at org.flexunit.runner::FlexUnitCore/runRequest()[E:\hudson\jobs\FlexUni t4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as :283]

    at org.flexunit.runner::FlexUnitCore/runClasses()[E:\hudson\jobs\FlexUni t4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as :269]

    at Function/http://adobe.com/AS3/2006/builtin::apply()

    at org.flexunit.runner::FlexUnitCore/run()[E:\hudson\jobs\FlexUnit4-Flex 4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:245]

    at com.berog.proj_drum_machine.tests::TestMain()[E:\Actionscript\project s\DrumMachine\src\com\berog\proj_drum_machine\tests\TestMain.as:18]

com.berog.proj_drum_machine.tests.matrix_test_suite.test_cases::Matrix ConstructorTest.testOne (1,1,,1,1,) E

Time: 0.013

There was 1 failure:

1 com.berog.proj_drum_machine.tests.matrix_test_suite.test_cases::Matri xConstructorTest.testOne (1,1,,1,1,) TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at flex.lang.reflect::Constructor/newInstanceApply()[E:\hudson\jobs\Flex Unit4-Flex4.1\workspace\FlexUnit4\src\flex\lang\reflect\Constructor.as :253]

    at TestClassRunnerForParameters/createTest()[E:\hudson\jobs\FlexUnit4-Fl ex4.1\workspace\FlexUnit4\src\org\flexunit\runners\Parameterized.as:45 5]

    at org.flexunit.runners::BlockFlexUnit4ClassRunner/methodBlock()[E:\huds on\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runners \BlockFlexUnit4ClassRunner.as:314]

    at org.flexunit.runners::BlockFlexUnit4ClassRunner/runChild()[E:\hudson\ jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runners\Bl ockFlexUnit4ClassRunner.as:152]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runners::Parameterized/runChild()[E:\hudson\jobs\FlexUni t4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runners\Parameterized. as:273]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runners::Suite/runChild()[E:\hudson\jobs\FlexUnit4-Flex4 .1\workspace\FlexUnit4\src\org\flexunit\runners\Suite.as:151]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runners::Suite/runChild()[E:\hudson\jobs\FlexUnit4-Flex4 .1\workspace\FlexUnit4\src\org\flexunit\runners\Suite.as:151]

    at org.flexunit.internals.runners::ChildRunnerSequencer/executeStep()[E: \hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\in ternals\runners\ChildRunnerSequencer.as:82]

    at org.flexunit.internals.runners.statements::StatementSequencer/handleC hildExecuteComplete()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexU nit4\src\org\flexunit\internals\runners\statements\StatementSequencer. as:141]

    at org.flexunit.internals.runners.statements::StatementSequencer/evaluat e()[E:\hudson\jobs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexu nit\internals\runners\statements\StatementSequencer.as:109]

    at org.flexunit.runners::ParentRunner/run()[E:\hudson\jobs\FlexUnit4-Fle x4.1\workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:483]

    at org.flexunit.runner::FlexUnitCore/beginRunnerExecution()[E:\hudson\jo bs\FlexUnit4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexU nitCore.as:348]

    at org.flexunit.runner::FlexUnitCore/runRunner()[E:\hudson\jobs\FlexUnit 4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as: 307]

    at org.flexunit.runner::FlexUnitCore/runRequest()[E:\hudson\jobs\FlexUni t4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as :283]

    at org.flexunit.runner::FlexUnitCore/runClasses()[E:\hudson\jobs\FlexUni t4-Flex4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as :269]

    at Function/http://adobe.com/AS3/2006/builtin::apply()

    at org.flexunit.runner::FlexUnitCore/run()[E:\hudson\jobs\FlexUnit4-Flex 4.1\workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:245]

    at com.berog.proj_drum_machine.tests::TestMain()[E:\Actionscript\project s\DrumMachine\src\com\berog\proj_drum_machine\tests\TestMain.as:18]

FAILURES!!! Tests run: 1, 1 Failures:

 

Can anyone help me?

 
Replies
  • Currently Being Moderated
    Oct 24, 2011 5:08 AM   in reply to BeeWrog

    Thanks for including a test case. I will try to replicate this morning

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2011 4:12 PM   in reply to BeeWrog

    Ben,

     

    Yes, I have replicated them. Don't have an answer yet but do have replication.

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2011 4:20 PM   in reply to Michael Labriola

    Actually, I do see what's wrong.

     

    When you call a method in the ActionScript universe, you can can usually do a function.apply() and pass it a variable number of args. Unfortunately, constructors are the one type of method where this doesn't work. You can't actually do an apply() so we have to fake it by having a map of static functions which each know how to apply a given number of arguments to the constructor. There is a check in the code that tests if the number of arguments you have exceeds what our static map knows how to apply.

     

    It looks like that check should have thrown the error:

     

    throw new ArgumentError("Sorry, we can't support constructors with more than " + argMap.length + " args out of the box... yes, its dumb, take a look at Constructor.as to modify on your own");

     

    It didn't and I am guessing its because there is a border condition here. So, what happening is that we only support up to 5 arguments right now. That number is arbitrary. When it was written it just seemed like a reasonable number, however, this class was written before Parameterized testing was introduced.

     

    Your three choices right now would be to use the TestNG style of Parameterized testing, which uses functions and not constructor args so it will not suffer this same fate, change the code and compile flexunit for yourself, or we could put a patched Constructor class in your project which fixes it. Longer term, I would like you to file a bug that we should increase the number to 10 or some other quasi-reasonable number. We will never be able to support an infinite number and we will always need to pick som arbitrary line in the sand. It just seems our line should be farther out.

     

    Mike


     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2011 5:55 PM   in reply to BeeWrog

    There is a flexunit category on bugs.adobe.com

     

    Thanks,

    mike

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)