• Jakub Lejtnar 4
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

We're getting an unexpected error message when we try to compile this on the line noted below: "Error: Compile Error: Expression of type TestClass.TestType has no member named A at line ....."

 

If we comment out the contents of runTest then it compiles fine. We suspect a bug in Apex in which static methods cannot reference enums. This is ironic because static testMethods can!


@isTest
private class FixAccountIdInSalsTest
{
    private enum TestType{A, B}
    
    private static testMethod void testForA()
    {
        runTest(TestType.A); // COMPILES FINE
    }

    private static testMethod void testForB()
    {
        runTest(TestType.B); // COMPILES FINE
    }
    
    private static void runTest(TestType testType)
    {
        Test.StartTest();
        if (TestType.A == testType) // COMPILER BREAKS HERE
        {
            // do something
        }
        else if (TestType.B == testType) // AND PRESUMABLY BREAKS HERE
        {
            // do something else
        }
    }
}