Skip navigation
paulhart83
Currently Being Moderated

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

Feb 12, 2013 8:50 AM

Tags: #problem #flash_builder #mobile #actionscript #mobile_project #compile #4.7

Hello!

 

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 {

 

                    [Before]

                    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";

 

                              MusicManager.setSongData(songData);

 

                    }

 

                    [Test]

                    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..."

 

And

 

"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.

 
Replies

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