Responsive Ad Area

Share This Post

test

how can I isolate the affect of @PrepareForTest only on one test case

I am pretty new in Mock and Mockto so forgive me if the answer to question is pretty obvious.
I have problem isolating affect of @prepareForTest on only one test case.
I tried to put @PrepareForTest(value = {myClassThatIWantToMock.class}) right on top of my test function. but it seems it is affecting other tests to fails.

@Test(expected = Exception.class)
@PrepareForTest(value = {myClassThatIWantToMock.class})
public void test() throws Exception {
    PowerMockito.mockStatic(HanaClientRequestUtils.class);
    PowerMockito.stub(PowerMockito.method(myClassThatIWantToMock.class, "someStaticFunction")).toReturn(testResource.getAsJsonObject("authenticationError"));
// some validation
}

any idea how I can prevent this?


how can I isolate the affect of @PrepareForTest only on one test case
how can I isolate the affect of @PrepareForTest only on one test case
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar