You need to sign in to do that
Don't have an account?
Static methods cannot reference enums?
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
}
}
}
For example, you could try updating the "runTest" method signature as follows, of course making sure to also update references to the "testType" variable within that method accordingly:
private static void runTest(TestType aType)
try to rename the variable from testType to something else so it differs from the enum name.