if(! fms.doesNeedToUpdateInputs()){ continue;
if (st.doesNeedToUpdateInputs()) { try{ st.updateMockedMethods();
@Test public void testAll_once() throws Exception { TestCase tc = new DefaultTestCase(); VariableReference ref = new VariableReferenceImpl(tc, Foo.class); FunctionalMockStatement mockStmt = new FunctionalMockStatement(tc, ref, new GenericClass(Foo.class)); VariableReference mock = tc.addStatement(mockStmt); VariableReference result = tc.addStatement(new MethodStatement(tc, new GenericMethod(this.getClass().getDeclaredMethod("all_once", Foo.class), FunctionalMockStatementTest.class), null, Arrays.asList(mock))); Assert.assertFalse(mockStmt.doesNeedToUpdateInputs()); Assert.assertEquals(0, mockStmt.getNumParameters()); //execute first time with default mock Scope scope = execute(tc); Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); List<Type> types = mockStmt.updateMockedMethods(); Assert.assertEquals(7,types.size()); }
@Test public void testAll_twice() throws Exception { TestCase tc = new DefaultTestCase(); VariableReference ref = new VariableReferenceImpl(tc, Foo.class); FunctionalMockStatement mockStmt = new FunctionalMockStatement(tc, ref, new GenericClass(Foo.class)); VariableReference mock = tc.addStatement(mockStmt); VariableReference result = tc.addStatement(new MethodStatement(tc, new GenericMethod(this.getClass().getDeclaredMethod("all_twice", Foo.class), FunctionalMockStatementTest.class), null, Arrays.asList(mock))); Assert.assertFalse(mockStmt.doesNeedToUpdateInputs()); Assert.assertEquals(0, mockStmt.getNumParameters()); //execute first time with default mock Scope scope = execute(tc); Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); List<Type> types = mockStmt.updateMockedMethods(); Assert.assertEquals(14,types.size()); }
Assert.assertFalse(mockStmt.doesNeedToUpdateInputs()); Assert.assertEquals(0, mockStmt.getNumParameters()); Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); List<Type> types = mockStmt.updateMockedMethods(); Assert.assertEquals(1,types.size());
Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); List<Type> types = mockStmt.updateMockedMethods(); Assert.assertEquals(LOOP_3, types.size()); execute(tc); Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); types = mockStmt.updateMockedMethods(); Assert.assertEquals(LOOP_5 - LOOP_3, types.size()); execute(tc); Assert.assertFalse(mockStmt.doesNeedToUpdateInputs()); //no update should be required types = mockStmt.updateMockedMethods(); Assert.assertEquals(0, types.size()); Assert.assertFalse(mockStmt.doesNeedToUpdateInputs()); //no update should be required types = mockStmt.updateMockedMethods(); Assert.assertEquals(0, types.size()); Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); //do update types = mockStmt.updateMockedMethods(); Assert.assertEquals(0, types.size()); // but no new types to add Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); //do update types = mockStmt.updateMockedMethods(); Assert.assertEquals(0, types.size()); // but no new types to add
Assert.assertFalse(mockStmt.doesNeedToUpdateInputs()); Assert.assertEquals(0, mockStmt.getNumParameters()); Assert.assertTrue(mockStmt.doesNeedToUpdateInputs()); List<Type> types = mockStmt.updateMockedMethods(); Assert.assertEquals(1,types.size());