Reputation: 65
I work on writing tests for some software where im writing integration tests. im using Jmock to mock some custom requestobjects and i have run into some problems I want to do the following:
setupMethod
context = new Mockery()
{
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
test = context.states("test");
context.checking(new Expectations()
{
{
Setup all expectations to default values
}
});
And then in my testcases i want to overwrite specific expections like so:
TestCase0
test.become("testCase0");
context.checking(new Expectations()
{
{
add new expectations with when state.is("testCase0")
that overwrites specific default expectations
}
});
When i try using my testCase0 expectations they return what i specified in the default expectations. Making it seem like my use of states does nothing?
Upvotes: 1
Views: 407
Reputation: 65
Okay i have found out how to solve this issue for the people who will come after me.
You set up your mock in each test case with the special expectations. Then you call a method that sets all default expectations. Because of the order the default values cannot overwrite the expectations you set in your test case.
Upvotes: 1