java.lang.IllegalStateException: no last call auf ein mock verfügbar mit PowerMock und EasyMock

Ich habe einen test-case mit PowerMock, um zu testen auf statische Methode aus der Mathematik, als

@RunWith(PowerMockRunner.class)
@PrepareForTest( { Math.class })
public class Test{
    @Test
        public void test2(){
            PowerMockito.mockStatic(Math.class);
            EasyMock.expect(Math.abs(-123)).andReturn(1);
            EasyMock.replay(Math.class);
            long returns = Math.abs(-123);
            EasyMock.verify(Math.class);
            org.junit.Assert.assertEquals(1,returns);
        }
}

Meine pom.xml sieht aus, als

<dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>

Und ich erhielt den Fehler wie

java.lang.IllegalStateException: no last call on a mock available
    at org.easymock.EasyMock.getControlForLastCall(EasyMock.java:559)
    at org.easymock.EasyMock.expect(EasyMock.java:537)

Dies ist das erste Zeit bin ich mit PowerMock, ich will einfach nur, um zu versuchen, um zu testen, statische Methode, und ich Wählen Sie die Java-Klasse Math test. Ich denke, ich habe getan, alle Teile in der Anleitung von https://code.google.com/p/powermock/wiki/MockStatic

Was ist Los mit meinem test-Fall?

InformationsquelleAutor Neil | 2015-09-29
Schreibe einen Kommentar