10 Replies Latest reply on Apr 30, 2010 11:35 AM by sanggpark

    FlexUnit assertionsMade statement validity

    Gnutronics

      Hello,

      Is the following FlexUnit Assert program statement valid?

       

      Assert.assertEquals(Assert.assertionsMade, 0);

       

      The flex4sdk_b2_100509 compiler reports an error.

       

      Thanks,

      A FlexUnit and ActionScript newbie

        • 1. Re: FlexUnit assertionsMade statement validity
          mlabriola Level 4

          It's valid. What error are you receiving so I can help more?

          • 2. Re: FlexUnit assertionsMade statement validity
            Gnutronics Level 1

            Hello mlabriola,

             

            Here's my error:

             

               [mxmlc] D:\Gnutronics\SW_dev\FlexUnit\ApplicationFramework\tests\TC999_Action_Search_Browse\src\s uite\cases\TestCaseThomAsUpnp0.as(89): col: 31 Error: Access of possibly undefined property assertionsMade through a reference with static type Class.
                [mxmlc]
                [mxmlc]                     Assert.assertEquals(Assert.assertionsMade, 0);
                [mxmlc]                                                ^
                [mxmlc]

             

            Thanks

            • 3. Re: FlexUnit assertionsMade statement validity
              mlabriola Level 4

              Can you share the import statement where you import the Assert class with me?

               

              Due to the fact that we support multiple testing frameworks, that could be an issue. There is an Assert class for FlexUnit 1 and 4 (which effectively just call each other but act as aliases) and one for Fluint. Only one of them has that property.

               

              Thanks,

              Mike

              • 4. Re: FlexUnit assertionsMade statement validity
                Gnutronics Level 1

                Mike,

                 

                Here's my Assert class import statement:

                import flexunit.framework.Assert;

                 

                My program also includes this import statement:

                import flash.net.getClassByAlias;

                 

                Thanks

                • 5. Re: FlexUnit assertionsMade statement validity
                  mlabriola Level 4

                  That's what I needed to know. Thanks.

                   

                  import flexunit.framework.Assert is the older FlexUnit assertion class from FlexUnit .9; it will work just fine, however, there is a typo in that class. Instead of assertionsMade, the property is called Assert.assetionsMade ... it is missing an 'r'. Our policy with FlexUnit 4 has been to work in a completely new environment and never break backward compatibility.

                   

                  Therefore, we include the FlexUnit 1 library, but never change it.. hence that typo is there forever.

                   

                  The FlexUnit 4 assertion class, which has the same functionality as the old but belongs to the newer package,etc. is in org.flexunit.Assert

                   

                  That class does have a property named assertionsMade, which you can use

                   

                  Mike

                  • 6. Re: FlexUnit assertionsMade statement validity
                    sanggpark Level 1

                    hmm couldn't you just write another property assertionsMade and make assetionMade (the old class) a wrapper of the new class? that way, it doesn't break backward compatibility and it makes sense for people new to FlexUnit.

                    • 7. Re: FlexUnit assertionsMade statement validity
                      mlabriola Level 4

                      Not really, for a couple of reasons.

                       

                      First, it is important to understand we do not emulate or run Fluint or FlexUnit .9 tests in FlexUnit 4. Quite literally when we come across one of those tests, we instantiate the original framework, let it run the test and we just provide a channel through FlexUnit 4 where the information can be reported back in one cohesive way.

                       

                      This means that FlexUnit 4 doesn't compile the code for FlexUnit .9, we use it as a library. There are a ton of FlexUnit .9 tests out there, so one of the first prerequisites for the new version is that we didn't change the old in any way. We had to use it 'as is' and simply interface where we could. This also means that when we build FlexUnit 4, we have a dependency on FlexUnit .9.

                       

                      Beyond the issue that we aren't supposed to change any code in .9 (and haven't so far), if we changed the class as suggested, that would means that the older version has a dependency on the newer version. Now we have circular issues as 4 depends on .9 and .9 depends on 4.

                       

                      Those are the two big issues along with a few smaller ones.

                       

                      Mike

                      • 8. Re: FlexUnit assertionsMade statement validity
                        sanggpark Level 1

                        ok wrong choice of words. my bad.

                         

                        I just mean you could do this in FlexUnit .9 library code.

                        public static function get assetionMade(): Number {      return assertionMade; }

                        public static function get assertionMade(): Number{      return _assertCount; }

                        I realize modifying FlexUnit .9 library is pretty pointless at this point since FlexUnit 4 is out and new people like me can just use FlexUnit 4 version of Assert and not worry about it. Well here's my problem. I'm one of those people. It only has been few weeks since I started to use FlexUnit. So in theory, I should've been using org.flexunit.Assert and should not have had any problems. However, since flexunit.framework.Assert was first choice for autocomplete in FlashBuilder, and I did not know that was FlexUnit .9 library, I was using flexunit.framework.Assert instead. Since reading this thread, I made switches but I would've been still using the old library had I not read this thread.
                        I guess I should've read the docs and realized that all the packages were in org.flexunit package .. but instead I just read the wiki and decided FlexUnit 4 was intuitive enough that I don't really need to consult the doc all that much. So yes it's partially my fault, but I think at least it should be stated somewhere in the wiki that new people should not use flexunit.framework package since it's FlexUnit .9 library.

                        • 9. Re: FlexUnit assertionsMade statement validity
                          mlabriola Level 4

                          i dont think it is your fault nor do i think it is pointless to modify the older lib. we are just trying to play nice as we were specifically asked to leave the older lib unmodified by adobe.  just trying to work within the rules that have the best outcome for the community

                           

                          i agree that this needs more documentation.. and perhaps there are other more evil solutions we could explore... perhaps a patch or something else... will gi e it some thoughts. if you are up for it, i would appreciate if you could find appropriate places to add these notes in the wiki docs

                          • 10. Re: FlexUnit assertionsMade statement validity
                            sanggpark Level 1

                            ahhh so it's adobe's restriction... i see. well I guess that's that then.

                            and somehow it didn't hit me that I could made the edits myself since it's a wiki. I guess I'll see if I can find a good place to add those notes.