5 Replies Latest reply on Feb 12, 2010 12:42 PM by mlabriola

    result from core.run null

    bmarrant Level 1

      Hi all,

       

      I'm testing out flexunit4 as an upgrade to flexunit 0.9 mainly for the verbose ant task and partially for the fluint integration.  I have two questions:

       

      when I run the following in flex unit 4:

       

      result = core.run(suite);

       

      result ends up being null.  In flexunit 0.9 I used this result object and now that code is breaking when I port it over.  Is there a way to get this result object in flexunit 4?

       

      Second, is there any way to get the type of failure reporting though ant that 4 has but using 0.9?

      ie. Does anyone know a way to get the following from 0.9:

       

      [

       

      flexunit] Suite: samplesuite.tests.testcase1

       

      [

       

      flexunit] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 sec

      [

       

      flexunit] Suite: samplesuite.tests.TestAsync

      [

       

      flexunit] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

      [flexunit]

      [

       

      flexunit] Results :

      [flexunit]

      [

       

      flexunit] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 sec

       

      Thanks,

      Brian

        • 1. Re: result from core.run null
          mlabriola Level 4

          General answer on the result, more details when I can look at the code.

           

          You can still get that result object, but you need to do so once the test finish. There is an event on the core for this.

           

          Basically, in FlexUnit4 we are broken across flash player frames and everything is potentially async, so we can't return the result object synchronously. We can only do it once the test have finished execution.

           

          Mike

          1 person found this helpful
          • 2. Re: result from core.run null
            bmarrant Level 1

            That makes sense.  I was poking around the code a bit already and all I could find were basic string dispatches.  There was some internal guys in core called notifier and some asyncListener which seemed to deal with result, but I didn't see anywhere it would actually dispatch anything with the result from core itself.

             

            Brian

            • 3. Re: result from core.run null
              mlabriola Level 4

              I am pretty sure there is another way to, but, you can def use the addListener() method of the core to add an object of type IRunListener, which will be notified as things change. Two of the methods of that interface are testRunStarted and testRunFinished which are called before anything starts and after everything finishes. Again, I think there is another event in there too we added for some UI work, but that one I am sure about (so long as my memory serves me correctly)

               

              Mike

              • 4. Re: result from core.run null
                bmarrant Level 1

                Alright, got it working, but I'm semi confused on what's there.  Here's the class I implemented to get the result:

                 

                    public class ResultCapturingRunListener extends RunListener
                    {
                        public function ResultCapturingRunListener()
                        {
                            super();
                        }

                 

                        override public function testRunFinished(result : Result) : void
                        {
                            this.result = result;
                        }
                    }

                 

                Looks like there are 3 classes that already implement IRunListener that I've seen.  The above RunListener and two classes that extend RunListener, TextListener and TraceListener.

                 

                Here's the part thats baffling me... RunListener is the class that declares the result member, but none of the mentioned classes actually set it, making the above class necessary.  Am I missing something, or would everyone who wants the result declared in the concrete RunListener have to extend it as I have?  Seems that this functionality should be built in as RunListener is declaring the variable?

                 

                In any case, I have it working the way I'd like.  Thanks for the help!

                 

                -Brian

                • 5. Re: result from core.run null
                  mlabriola Level 4

                  It sounds like a bug. The base RunListener should set it at test completion.

                   

                  It is quite common that other classes may not need that result persisted, but that functionality should exist in the base class.