How to use Bean method of org.jmock.test.acceptance.InvocationDescriptionAcceptanceTests class

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

Source:InvocationDescriptionAcceptanceTests.java Github

copy

Full Screen

...13 */14public class InvocationDescriptionAcceptanceTests {15 private static final String UNEXPECTED_ARGUMENT = "unexpected argument";16 private final JUnit4Mockery aMockContext = new JUnit4Mockery();17 private final SubBean aSubBean = aMockContext.mock(SubBean.class);18 private final Collaborator aCollab = aMockContext.mock(Collaborator.class);19 // https://github.com/jmock-developers/jmock-library/issues/2020 @ParameterizedTest21 @ArgumentsSource(ImposteriserParameterResolver.class)22 public void doesNotModifyInvocationsWhileReportingFailure(Imposteriser imposteriserImpl) {23 final Bean lBean = new Bean(aSubBean);24 aMockContext.checking(new Expectations() {{25 allowing(aSubBean).count(); will(returnValue(123));26 oneOf(aCollab).message("xyzzy", lBean);27 }});28 try {29 new Subject(aCollab).doIt(lBean);30 } catch (AssertionError expected) {31 assertThat(expected.getMessage(), containsString("collaborator.message(\"unexpected argument\", <Bean{123}>)"));32 return;33 }34 fail("should have thrown exception");35 }36 static class Bean {37 private final SubBean aSubBean;38 public Bean(SubBean pSubBean) {39 aSubBean = pSubBean;40 }41 @Override42 public String toString() { // called via describeTo() when reporting error43 return String.format("Bean{%d}", aSubBean.count());44 }45 }46 interface SubBean {47 int count();48 }49 interface Collaborator {50 void message(String pX, Bean pBean);51 }52 static class Subject {53 private final Collaborator aCollab;54 public Subject(Collaborator pCollab) {55 aCollab = pCollab;56 }57 @SuppressWarnings("UnusedDeclaration")58 void doIt(Bean pBean) {59 aCollab.message(UNEXPECTED_ARGUMENT, pBean);60 }61 }62}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Jmock-library automation tests on LambdaTest cloud grid

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

Most used method in InvocationDescriptionAcceptanceTests

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful