Skip navigation
Sébastien VARLET
Currently Being Moderated

Error while running Parameterized test

Sep 30, 2010 1:41 AM

Hi,

 

I'm currently working on a really simple Parameterized TestCase. I'm using flexunit 4.0-rc1 and flexmojos 3.5.0.

 

When I do 'mvn clean test' I get the following error:

 

<testsuite errors="0" failures="1" name="com.finams.bnpflexlib.utils.StringUtilsTest" tests="1" time="0">
  <testcase name="initializationError" time="0">
    <failure message="Custom runner class org.flexunit.runners.Parameterized cannot be instantiated" type="com.finams.bnpflexlib.utils.StringUtilsTest">Error: Custom runner class org.flexunit.runners.Parameterized cannot be instantiated
     at org.flexunit.internals.runners::InitializationError()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\internals\runners\InitializationError.as:50]
     at org.flexunit.internals.builders::MetaDataBuilder/createInitializationError()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\internals\builders\MetaDataBuilder.as:209]
     at org.flexunit.internals.builders::MetaDataBuilder/buildWithSecondSignature()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\internals\builders\MetaDataBuilder.as:179]
     at org.flexunit.internals.builders::MetaDataBuilder/buildRunner()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\internals\builders\MetaDataBuilder.as:146]
     at org.flexunit.internals.builders::MetaDataBuilder/runnerForClass()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\internals\builders\MetaDataBuilder.as:115]
     at org.flexunit.runners.model::RunnerBuilderBase/safeRunnerForClass()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runners\model\RunnerBuilderBase.as:63]
     at org.flexunit.internals.builders::AllDefaultPossibilitiesBuilder/runnerForClass()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\internals\builders\AllDefaultPossibilitiesBuilder.as:106]
     at org.flexunit.runners.model::RunnerBuilderBase/safeRunnerForClass()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runners\model\RunnerBuilderBase.as:63]
     at org.flexunit.runners.model::RunnerBuilderBase/localRunners()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runners\model\RunnerBuilderBase.as:119]
     at org.flexunit.runners.model::RunnerBuilderBase/runners()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runners\model\RunnerBuilderBase.as:87]
     at org.flexunit.runners::Suite()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runners\Suite.as:170]
     at org.flexunit.runner::Request$/classes()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runner\Request.as:201]
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at org.flexunit.runner::FlexUnitCore/runClasses()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:191]
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at org.flexunit.runner::FlexUnitCore/run()[C:\Users\dmoore\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:171]
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at org.sonatype.flexmojos.unitestingsupport.flexunit4::FlexUnit4Listener/run()[/home/nexus/flexmojos/trunk/target/checkout/flexmojos-testing/flexmojos-unittest-flexunit4/src/main/flex/org/sonatype/flexmojos/unitestingsupport/flexunit4/FlexUnit4Listener.as:42]
     at org.sonatype.flexmojos.unitestingsupport::SocketReporter/runTests()[/home/nexus/flexmojos/trunk/target/checkout/flexmojos-testing/flexmojos-unittest-support/src/main/flex/org/sonatype/flexmojos/unitestingsupport/SocketReporter.as:243]
     at org.sonatype.flexmojos.unitestingsupport::TestApplication/runTests()[/home/nexus/flexmojos/trunk/target/checkout/flexmojos-testing/flexmojos-unittest-support/src/main/flex/org/sonatype/flexmojos/unitestingsupport/TestApplication.as:40]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
     at mx.core::UIComponent/set initialized()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169]
     at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628]
     at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]</failure>
  </testcase>
</testsuite>

 

Here is my TestCase (StringUtils is a simple class with a single method that converts numbers to strings, I did it to manage the specific case of a NaN parameter):

 

package com.finams.bnpflexlib.utils
{
     import org.flexunit.Assert;
     import org.flexunit.runners.Parameterized;
     import com.finams.bnpflexlib.utils.StringUtils;
     
     [RunWith("org.flexunit.runners.Parameterized")]
     public class StringUtilsTest
     {
          [Datapoints]
          static public var referential:Array = [
               {numeric: 0, alpha: '0'},
               {numeric: 1500, alpha: '1500'},
               {numeric: 42, alpha: '42'},
               {numeric: 15.15, alpha: '15.15'},
               {numeric: 999, alpha: '999'},
               {numeric: 17.0123456789, alpha: '17.0123456789'},
               {numeric: 123456789, alpha: '123456789'},
               {numeric: 0.00000000001, alpha: '0.00000000001'},
               {numeric: -1, alpha: '-1'},
               {numeric: 0.00000000015, alpha: '0.00000000015'},
               {numeric: -1.01, alpha: '-1.01'},
               {numeric: 0.12345678912, alpha: '0.12345678912'},
               {numeric: -123456789, alpha: '-123456789'},
               {numeric: 0.0, alpha: '0.0'},
               {numeric: -1.123456789, alpha: '-1.123456789'},
               {numeric: -0.0, alpha: '-0.0'}
          ];
          
          public function StringUtilsTest() {}
 
          [Test(description="Ensure that a NaN number will produce an empty string.")]
          public function checkNbToStringWithNaNParameter():void
          {
               var result:String;
               
               result = StringUtils.nbToString(NaN);
               
               Assert.assertEquals(result, '');
          }
          
          [Ignore]
          [Test(dataprovider="referential", description="Check conversion with a set of values")]
          public function checkNumbers(nb:Number, ref:String):void
          {
               var result:String;
               
               result = StringUtils.nbToString(nb);
               
               Assert.assertEquals('Conversion fault: expected ' + ref + ', got ' + nb.toString(),
                              result,
                              'ref');
          }
     }
}

 

I wonder what's wrong...

 
Replies
  • Currently Being Moderated
    Sep 30, 2010 2:15 AM   in reply to Sébastien VARLET

    in actionscript metadata is a string. since there isnt an actual reference to the parameterized runner class anywhere in your code, the linker isnt including it in the final swf. when the metadata string is evaluated at runtime, it cannot find the runner class in memory as it will not exist in that swf

     

    two options. ensure the runner is linked in by making reference to it in the test case somewhere. use the second release candidate where we force it to be linked in because a lot of people were having similar issues

     

    hope that explains and helps

    mike

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 30, 2010 3:56 AM   in reply to Sébastien VARLET

    Okay, I see two more problems

     

    Problem #1, [Test(dataprovider= ... the 'p' in dataProvider should be capitalized. If you get a chance, also file this as an enhancement so we can look for either or at least warn.

     

    Problem #2, the dataprovider is not formed correctly. It needs to be an array of arrays, so:

     

    static public var referential:Array = [

    [0, '0'],

    [1500, '1500']

    ];

    I think that will fix the situation.
    Another issue we clearly have is that, in the case where something is marked Ignore, we shouldn't even bother going to look for the dataProvider.
    I think this will get you running,
    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 30, 2010 4:43 AM   in reply to Sébastien VARLET

    Hi,

    Regarding using later versions of FlexUnit, you may want to take a look at:

    http://groups.google.com/group/flex-mojos/browse_thread/thread/cd93873 17c744d37/aebf9317df2f17fe?#aebf9317df2f17fe

     

    Obviously, ideally all one needs is placing the new libraries in a repository and using (but sometimes this isn't an ideal World ;-) )

    HTH, R.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 30, 2010 6:31 AM   in reply to Sébastien VARLET

    the dot zero release of flexunit doesnt have parameterized testing, only dot one versions. so using the swc you mention in your edit will fail. i am also concerned as your post of error messages shows a developers name.. dmoore... this means it is not a release build in any way. iall release builds are built from our server. somewhere you are getting a really old development lib and not a approved version

     

    can you try to grab a version from builds.flexunit.org

     

    mike

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 30, 2010 7:42 AM   in reply to Sébastien VARLET

    Glad to hear it.

     

    One final note. The [DataPoints[ metadata you have in your example is extraneous. It won't hurt anything but it isn't needed either.

     

    Cheers,

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 1, 2010 4:02 AM   in reply to Sébastien VARLET

    The DataPoint and DataPoints metadata is used by the Theory runner. It is not used by the Parameterized runner, so it is just being ignored in your case.

     

    So it is used, just not in this context, so here it is ignored.

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 7, 2010 4:40 AM   in reply to Michael Labriola

    Interesting to know about [Datapoints]. Someone may wish to update the wiki at some stage? http://docs.flexunit.org/index.php?title=Parameterized_Test_Styles

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 7, 2010 4:50 AM   in reply to pdkn

    agreed. side note. we are a completely volunteer unfunded open source project and the wiki is open to editing. so should anyone want to fix this before the limited team here can address, it is always greatly appreciated.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 7, 2010 10:07 AM   in reply to Michael Labriola

    Ooh, didin't realise I can edit wiki - will get to it...

     
    |
    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