• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

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

Guest
Feb 11, 2013 Feb 11, 2013

Copy link to clipboard

Copied

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.

Views

805

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 12, 2013 Feb 12, 2013

Copy link to clipboard

Copied

LATEST

I did some more work on the issue above. There are functions with in the MusicManager that call the UserManager to get a user's ID. When I comment out these calls then the access errors go away. Well the user manager has some calls back to mxml that tell the class that changes where made. My best guess is this is where it stems into the code that is randomly throwing errors. But, it compiles fine and runs fine on a device. Is there something with test cases which doesn't invoke the UI?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines