Avinash Jadhav
Avinash Jadhav

Reputation: 1393

Mockito test for method returning String

I want to write mockito test for code given below. Is there any solution?

 @Override
public String getPortDirection()
{
    return NameTokens.INPUT_PORT_DIRECTION_VALUE;
}

Upvotes: 2

Views: 2389

Answers (2)

Craig
Craig

Reputation: 2366

If you want to mock the value of the static field (with null), then you'll have to use PowerMockito. Take a look at this answer: https://stackoverflow.com/a/8911517/529256 Basic Mockito cannot mock static methods, fields, or constructors.

Upvotes: 0

slartidan
slartidan

Reputation: 21576

I'm not sure, wether the test will be helpfull, but it is at least easy to implement:

@Test
public void checkPortDirection() {
    assertEquals(NameTokens.INPUT_PORT_DIRECTION_VALUE, getPortDirection());
}

Mockito is not used in this Test, just JUnit.

Upvotes: 1

Related Questions