void () { myFixture.addClass("package com.intellij.java.psi; public class ConstantEvaluatorTest { public enum MyEnum { Foo, Bar } }"); myFixture.configureByText("Test.java", "import com.intellij.java.psi.ConstantEvaluatorTest; class Foo { ConstantEvaluatorTest.MyEnum e = ConstantEvaluatorTest.MyEnum.Foo; }"); PsiClass psiClass = ((PsiJavaFile)getFile()).getClasses()[0]; PsiField field = psiClass.findFieldByName("e", false); assertNotNull(field); PsiExpression initializer = field.getInitializer(); assertNotNull(initializer); Object result = JavaPsiFacade.getInstance(getProject()).getConstantEvaluationHelper().computeConstantExpression(initializer); assertEquals(MyEnum.Foo, result); }