Пример #1
0
 @Test(dataProvider = "memberTestCase")
 public void memberTest(
     AccessModifier accessModifier,
     CodeChunk codeChunk,
     Static isStaticMember,
     Static isStaticReference) {
   MemberTestCase testCase =
       new MemberTestCase(accessModifier, codeChunk, isStaticMember, isStaticReference);
   assertEval(testCase.generateSource());
   String expectedMessage = testCase.expectedMessage;
   if (testCase.codeChunk != CodeChunk.CONSTRUCTOR || testCase.isAccessible()) {
     assertEval("A a = new A();");
   }
   if (expectedMessage == null) {
     assertEval(testCase.useCodeChunk());
   } else {
     assertDeclareFail(testCase.useCodeChunk(), expectedMessage);
   }
 }
Пример #2
0
 @Test(dataProvider = "memberTestCase")
 public void extendsMemberTest(
     AccessModifier accessModifier,
     CodeChunk codeChunk,
     Static isStaticMember,
     Static isStaticReference) {
   MemberTestCase testCase =
       new ExtendsMemberTestCase(accessModifier, codeChunk, isStaticMember, isStaticReference);
   String input = testCase.generateSource();
   List<String> ss = parseCode(input);
   assertEval(ss.get(0));
   if (testCase.codeChunk != CodeChunk.CONSTRUCTOR || testCase.isAccessible()) {
     assertEval(ss.get(1));
     assertEval("B b = new B();");
   }
   String expectedMessage = testCase.expectedMessage;
   if (expectedMessage == null) {
     assertEval(testCase.useCodeChunk());
   } else {
     assertDeclareFail(testCase.useCodeChunk(), expectedMessage);
   }
 }