1 Reply Latest reply on Feb 12, 2013 8:53 AM by paulhart83

    Call to a possibly undefined method displays when using static function in Unit Test

    paulhart83 Level 1



      This has been driving me nuts. I am setting up unit tests for a static class which manages a collection of songs. This is how my unit test class looks:


      //START CODE


      package flexUnitTests {


                import com.myapp.managers.MusicManager;

                import flash.utils.Dictionary;

                import flexunit.framework.Assert;


                public class MyAppManagerTest {



                          public function setUp():void {


                                    var songData:Dictionary = new Dictionary();


                                    songData["mn0012345"] = new Dictionary();

                                    songData["mn0012345"]["title"] = "All the Pretty Little Horses";

                                    songData["mn0012345"]["description"] = "by: American Traditional | Voice, Piano | 3 pages";







                          public function test_getAuthorsBySKU():void {



                                    var expected:String = "American Traditional";

                                    var given:String = MusicManager.getAuthorsBySKU("mn0012345");


                                    Assert.assertEquals(expected, given);








      //END OF CODE


      You will notice two calls in red above. When I leave them in the code I see a variety of errors which look like this:


      "Call to a possibly undefined method '' through a reference with a static type com.myapp..."




      "Access of possible undefined property '' through a reference with static type com.myapp..."


      Then, when I comment out the two lines in red above, these errors go away. Flash Builder seems really flakey to me. Often I notice that the error list varies, how can it just no longer be an error? Where did this new access error come from, in a no related part of the code, by adding or removing a function call to a static class which remains in the import statement.


      Note that the MusicManager contains no references to any of the UI mxml that is throwing these errors. It just simply loads data into a few globals and allows you to grab info.


      How is my usage of this function making foreign objects inaccessible?


      Please help!!! I am really hoping there is an answer but I have a bad feeling the answer is just that Flash Builder is flakey.