-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Complete
-
Affects Version/s: 1.1.3.RELEASE
-
Fix Version/s: 1.1.4.RELEASE
-
Component/s: TESTING
-
Labels:None
The generated mock test requires mocking of static entity methods, and as such won't run as is. Current code is missing a class-level annotation, @MockStaticEntityMethods, which will make the code function properly.
Incorrect version:
package org.rooina.coursemanager.model; import org.junit.Test; public class StudentTest { @Test public void testMethod() { int expectedCount = 13; Student.countStudents(); org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.expectReturn(expectedCount); org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.playback(); org.junit.Assert.assertEquals(expectedCount, Student.countStudents()); } }
Correct version:
package org.rooina.coursemanager.model; import org.junit.Test; import org.springframework.mock.staticmock.MockStaticEntityMethods; @MockStaticEntityMethods public class StudentTest { @Test public void testMethod() { int expectedCount = 13; Student.countStudents(); org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.expectReturn(expectedCount); org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.playback(); org.junit.Assert.assertEquals(expectedCount, Student.countStudents()); } }