How to use OverrideExpectationsFromSetUpAcceptanceTests class of org.jmock.test.acceptance package

Best Jmock-library code snippet using org.jmock.test.acceptance.OverrideExpectationsFromSetUpAcceptanceTests

Run Jmock-library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1package org.jmock.test.acceptance;
2
3import junit.framework.TestCase;
4
5import org.jmock.Expectations;
6import org.jmock.Mockery;
7import org.jmock.States;
8import org.jmock.api.ExpectationError;
9
10public class OverrideExpectationsFromSetUpAcceptanceTests extends TestCase {
11    Mockery mockery = new Mockery();
12    MockedType mock = mockery.mock(MockedType.class, "mock");
13    
14    States test = mockery.states("test").startsAs("settingUp");
15    
16    @Override
17    public void setUp() {
18        mockery.checking(new Expectations() {{
19            allowing (mock).doSomethingWith(with(any(String.class))); when(test.is("settingUp"));
20        }});
21        
22        // These would be called by the object under test, during set-up
23        mock.doSomethingWith("foo");
24        mock.doSomethingWith("bar");
25        
26        test.become("ready");
27    }
28    
29    public void testSomething() {
30        mockery.checking(new Expectations() {{
31            oneOf (mock).doSomethingWith("whee");
32        }});
33        
34        try {
35            // This would be called by the object under test, during the test.
36            // It should be detected as a test failure, because the 'allowing'
37            // expectations defined during set-up no longer apply
38            mock.doSomethingWith("whoo");
39            fail("should have thrown ExpectationError");
40        }
41        catch (ExpectationError expected) {}
42    }
43}
44
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

...Most popular Stackoverflow questions on OverrideExpectationsFromSetUpAcceptanceTests

    No relevant questions found for this class 😞

Most used methods in OverrideExpectationsFromSetUpAcceptanceTests

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)