How to use method of org.jmock.test.unit.internal.CardinalityTests class

Best Jmock-library code snippet using org.jmock.test.unit.internal.CardinalityTests.

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.unit.internal;
2
3import junit.framework.TestCase;
4
5import org.hamcrest.StringDescription;
6import org.jmock.internal.Cardinality;
7import org.jmock.test.unit.support.AssertThat;
8
9public class CardinalityTests extends TestCase {
10    public void testDescribesOnceCardinality() {
11        AssertThat.stringIncludes("should describe exact invocation count",
12                                  "once", StringDescription.toString(new Cardinality(1, 1)));
13    }
14
15    public void testDescribesExactCardinality() {
16        AssertThat.stringIncludes("should describe exact invocation count",
17                                  "exactly 2", StringDescription.toString(new Cardinality(2, 2)));
18    }
19
20    public void testDescribesAtLeastCount() {
21        AssertThat.stringIncludes("should describe at-least invocation count",
22                                  "at least 2", 
23                                  StringDescription.toString(new Cardinality(2, Integer.MAX_VALUE)));
24    }
25
26    public void testDescribesAtMostCount() {
27        AssertThat.stringIncludes("should describe at-most invocation count",
28                                  "at most 2", StringDescription.toString(new Cardinality(0, 2)));
29    }
30
31    public void testDescribesBetweenCount() {
32        AssertThat.stringIncludes("should describe between invocation count",
33                                  "2 to 4", StringDescription.toString(new Cardinality(2, 4)));
34    }
35
36    public void testDescribesNeverCount() {
37        AssertThat.stringIncludes("should describe 'never' invocation count",
38                                  "never", StringDescription.toString(new Cardinality(0,0)));
39    }
40
41    public void testDescribesAnyNumberCount() {
42        final Cardinality allowed = new Cardinality(0, Integer.MAX_VALUE);
43        
44        AssertThat.stringIncludes("should describe 'allowed' invocation count",
45                                  "allowed", StringDescription.toString(allowed));
46        AssertThat.stringExcludes("should not include 'expected' in description",
47                                  "expected", StringDescription.toString(allowed));
48    }
49
50    public void testHasARequiredAndMaximumNumberOfExpectedInvocations() throws Throwable {
51        Cardinality cardinality = new Cardinality(2, 3);
52        
53        assertTrue(cardinality.allowsMoreInvocations(0));
54        assertFalse(cardinality.isSatisfied(0));
55        
56        assertTrue(cardinality.allowsMoreInvocations(1));
57        assertFalse(cardinality.isSatisfied(1));
58        
59        assertTrue(cardinality.allowsMoreInvocations(2));
60        assertTrue(cardinality.isSatisfied(2));
61        
62        assertFalse(cardinality.allowsMoreInvocations(3));
63        assertTrue(cardinality.isSatisfied(3));
64    }
65
66}
67
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)