9 Replies Latest reply on Jun 25, 2010 9:11 AM by Simeon Bateman

    Test dataProviders in 4.1 beta 2?

    msakrejda Level 4

      I'm using the 4.1 beta 2 download from here: http://www.flexunit.org/?page_id=14

       

      I have a test using the new dataProvider mechanism:

       

              public function getDates():Array {
                  function getBytes(str:String):ByteDataStream {
                      var bytes:ByteDataStream = new ByteDataStream();
                      bytes.writeUTFBytes(str);
                      bytes.position = 0;
                      return bytes;               
                  };
                  var format:BasicFieldDescription = new BasicFieldDescription(Oid.TIMESTAMP, EncodingFormat.TEXT);
                  return [
                      [ getBytes('2000-01-01 00:00:00'), format, { DateStyle: DateStyle.OUTPUT_ISO }, new Date(2000, 0, 1, 0, 0, 0) ]
                  ];
              }

       

              [Test(dataProvider="getDates")]
              public function testDecodeDate(bytes:ByteDataStream, format:IFieldInfo, serverParams:Object, expected:Date):void {
                  var result:Date = _decoder.decode(bytes, format, serverParams) as Date;
                  Assert.assertEquals(expected, result);
              }

       

      When I run this, I get the error

       

          Method testDecodeDate should have no parameters

       

      Any ideas?

        • 1. Re: Test dataProviders in 4.1 beta 2?
          msakrejda Level 4

          Ah, I was missing the [RunWith] metadata. It'd be nice if that were automagic, but I suppose that's kind of a minor detail to complain about.

          • 2. Re: Test dataProviders in 4.1 beta 2?
            Simeon Bateman Level 2

            Hi There,

             

            FlexUnit relies on different runners to correctly execute different types of tests.  Normally the default is the FlexUnit 4 runner, however parameterized tests are not supported.  They have their own runner.

             

            If you mark the class with the following metadata your tests will run correctly with the right runner.

             

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

             

            Hope that helps.

             

            Simeon Bateman

            simeon@pnwrain.com

            Principal Instigator

            PNW Rain LLC

            • 3. Re: Test dataProviders in 4.1 beta 2?
              msakrejda Level 4

              Hmm, so I guess my problem is not quite solved. I am now getting errors even on the "hello world" tests here:

               

              http://docs.flexunit.org/index.php?title=Parameterized_Test_Styles

               

              The errors are always just

               

              There was an error retrieving the parameters for the testcase: cause InitializationError

               

              The (relevant part of the) stack trace is:

               

              at org.flexunit.runners::Parameterized/buildErrorRunner()[E:\hudson\jobs\FlexUnit4-Flex3.5\w orkspace\FlexUnit4\src\org\flexunit\runners\Parameterized.as:130]
              at org.flexunit.runners::Parameterized/buildRunners()[E:\hudson\jobs\FlexUnit4-Flex3.5\works pace\FlexUnit4\src\org\flexunit\runners\Parameterized.as:151]
              at org.flexunit.runners::Parameterized/get children()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace\FlexUnit4\src\org\flexunit\runners\ Parameterized.as:215]
              at org.flexunit.runners::ParentRunner/getFilteredChildren()[E:\hudson\jobs\FlexUnit4-Flex3.5 \workspace\FlexUnit4\src\org\flexunit\runners\ParentRunner.as:397]
              at org.flexunit.runners::ParentRunner/get description()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace\FlexUnit4\src\org\flexunit\runne rs\ParentRunner.as:158]
              at org.flexunit.runners::Suite/describeChild()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace\Fl exUnit4\src\org\flexunit\runners\Suite.as:108]
              at org.flexunit.runners::ParentRunner/get description()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace\FlexUnit4\src\org\flexunit\runne rs\ParentRunner.as:163]
              at org.flexunit.runner::FlexUnitCore/beginRunnerExecution()[E:\hudson\jobs\FlexUnit4-Flex3.5 \workspace\FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:321]
              at org.flexunit.runner::FlexUnitCore/runRunner()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace\ FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:284]
              at org.flexunit.runner::FlexUnitCore/runRequest()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace \FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:260]
              at org.flexunit.runner::FlexUnitCore/runClasses()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace \FlexUnit4\src\org\flexunit\runner\FlexUnitCore.as:246]
              at Function/http://adobe.com/AS3/2006/builtin::apply()
              at org.flexunit.runner::FlexUnitCore/run()[E:\hudson\jobs\FlexUnit4-Flex3.5\workspace\FlexUn it4\src\org\flexunit\runner\FlexUnitCore.as:222]

              • 4. Re: Test dataProviders in 4.1 beta 2?
                Simeon Bateman Level 2

                Have you tried it with a simpler data provider? I am curious if maybe your function with inner function is not returning quite what you are expecting. Its possible that there is a bug in there, but it would be good to simplify a bit and make sure things work the way you expect.

                 

                I have been using the testNG style test and have had no issues. I say simplify it a bit and if you still get the same errors then we will see if anybody on the dev team can point something out.

                 

                Simeon Bateman

                simeon@pnwrain.com

                Principal Instigator

                PNW Rain LLC

                • 5. Re: Test dataProviders in 4.1 beta 2?
                  msakrejda Level 4

                  Yep, in the process of doing that now. As I'd said, the "hello world" tests are giving me the same error. I've set up FlexUnit4 and the UI runner in FB, so I'm able to dig into the errors. I resolved that issue (I accidentally also configured the Parameterized runner for my suite itself), but I'm currently getting "No runnable methods" for my Suite. As far as I can tell, it's declared identically to the FlexUnit4Suite (ignoring the tests themselves):

                   

                      import org.postgresql.pegasus.codec.decode.TestDecodeDate;

                   

                      [Suite]
                      [RunWith("org.flexunit.runners.Suite")]
                      /**
                       * @private
                       */
                      public class CodecSuite {
                          public var testDecodeDate:TestDecodeDate;
                      }

                   

                  I'll keep looking. Thanks for the help.

                  • 6. Re: Test dataProviders in 4.1 beta 2?
                    msakrejda Level 4

                    Ok, if anyone runs into the same issue: I think I was originally having problems due to bad metadata, but then, once I set up the FlexUnit dependency as a project reference (to debug the original issue), I seemed to get my metadata stripped somewhere (or something weird like that). Once I went back to .swcs, everything seems to be working fine. Thanks for the help, Simeon.

                    • 7. Re: Test dataProviders in 4.1 beta 2?
                      mlabriola Level 4

                      When we build the FlexUnit4 library (and in the project files you can download) you will see the following additional compiler argument:

                       

                      -keep-as3-metadata+=RunWith,BeforeClass,AfterClass,Before,After,Suite,Test,TestCase,Ignore ,Theory,DataPoint,DataPoints,ArrayElementType,Rule,Parameters

                       

                      (that should all be one line with no spaces)

                       

                      It seems like when you are building the library on your own that is missing. My guess is that when moving between SDKs or perhaps just importing projects to try multiple things that was somehow lost. It would cause the symptoms you are indicating.

                       

                      When a library is built with these options, a project using that library inherits the option. That is why it works when you use our SWC.

                       

                      Mike

                      1 person found this helpful
                      • 8. Re: Test dataProviders in 4.1 beta 2?
                        msakrejda Level 4

                        Ah, right. I completely forgot how custom metadata works. You're right--that must have been it.

                        • 9. Re: Test dataProviders in 4.1 beta 2?
                          Simeon Bateman Level 2

                          Glad you found a resolution for this.

                           

                          Simeon Bateman

                           

                          Principal Instigator

                          PNW Rain LLC

                          simeon@pnwrain.com