How to use method of org.easymock.tests.IMockBuilderTest class

Best Easymock code snippet using org.easymock.tests.IMockBuilderTest.

Run Easymock automation tests on LambdaTest cloud grid

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

copy
1/*
2 * Copyright 2001-2021 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.easymock.tests;
17
18import org.easymock.EasyMock;
19import org.easymock.IMockBuilder;
20import org.easymock.IMocksControl;
21import org.easymock.MockType;
22import org.junit.Test;
23
24import static org.easymock.EasyMock.partialMockBuilder;
25import static org.junit.Assert.assertEquals;
26import static org.junit.Assert.assertNotNull;
27import static org.junit.Assert.assertSame;
28
29/**
30 * Testing that all default methods on IMockBuilder are delegating to the right method.
31 *
32 * @author Henri Tremblay
33 */
34public class IMockBuilderTest {
35
36    private final IMockBuilder<IMockBuilderTest> builder = partialMockBuilder(IMockBuilderTest.class);
37
38    private void assertMock(IMockBuilderTest mock, String name, MockType type) {
39        assertEquals(name, Util.getName(mock));
40        assertEquals(type, Util.getType(mock));
41        assertNotNull(Util.getControl(mock));
42    }
43
44    private void assertMock(IMockBuilderTest mock, String name, MockType type, IMocksControl control) {
45        assertMock(mock, name, type);
46        assertSame(control, Util.getControl(mock));
47    }
48    @Test
49    public void testMock() {
50        IMockBuilderTest mock = builder.mock();
51        assertMock(mock, null, MockType.DEFAULT);
52    }
53
54    @Test
55    public void testNiceMock() {
56        IMockBuilderTest mock = builder.niceMock();
57        assertMock(mock, null, MockType.NICE);
58    }
59
60    @Test
61    public void testStrictMock() {
62        IMockBuilderTest mock = builder.strictMock();
63        assertMock(mock, null, MockType.STRICT);
64    }
65
66    @Test
67    public void testMockWithName() {
68        IMockBuilderTest mock = builder.mock("a");
69        assertMock(mock, "a", MockType.DEFAULT);
70    }
71
72    @Test
73    public void testNiceMockWithName() {
74        IMockBuilderTest mock = builder.niceMock("a");
75        assertMock(mock, "a", MockType.NICE);
76    }
77
78    @Test
79    public void testStrictMockWithName() {
80        IMockBuilderTest mock = builder.strictMock("a");
81        assertMock(mock, "a", MockType.STRICT);
82    }
83
84    @Test
85    public void testMockWithType() {
86        IMockBuilderTest mock = builder.mock(MockType.NICE);
87        assertMock(mock, null, MockType.NICE);
88    }
89
90    @Test
91    public void testMockWithNameAndType() {
92        IMockBuilderTest mock = builder.mock("a", MockType.NICE);
93        assertMock(mock, "a", MockType.NICE);
94    }
95
96    @Test
97    public void testMockWithControl() {
98        IMocksControl control = EasyMock.createNiceControl();
99        IMockBuilderTest mock = builder.mock(control);
100        assertMock(mock, null, MockType.NICE, control);
101    }
102
103    @Test
104    public void testMockWithNameAndControl() {
105        IMocksControl control = EasyMock.createNiceControl();
106        IMockBuilderTest mock = builder.mock("a", control);
107        assertMock(mock, "a", MockType.NICE, control);
108    }
109}
110
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

Trigger code on LambdaTest Cloud Grid

Execute automation tests with on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

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)