2016-09-30 12 views
8

मैं है निम्न परीक्षण ...PowerMockito ClassNotPreparedException फेंकने भी @PrepareForTest साथ स्काला टेस्ट

import org.scalatest.junit.JUnitRunner 
... 
@PowerMockRunnerDelegate(classOf[JUnitRunner]) 
@PrepareForTest(Array(classOf[AuditLog])) 
class ConnectorAPITest extends path.FreeSpec with ShouldMatchers { 
    "Mocked Tests" - { 
     println("This got called in the mocked tests.") 
     PowerMockito.mockStatic(classOf[AuditLog]); 
     ... 
    } 
} 

लेकिन मैं मिलता है जब मैं चलाने ...

An exception or error caused a run to abort: The class com.paxata.services.log.AuditLog not prepared for test. 
To prepare this class, add class to the '@PrepareForTest' annotation. 
In case if you don't use this annotation, add the annotation on class or method level. 
org.powermock.api.mockito.ClassNotPreparedException: 
The class com.paxata.services.log.AuditLog not prepared for test. 
To prepare this class, add class to the '@PrepareForTest' annotation. 

कौन सा मतलब नहीं है का उपयोग करते हुए एनोटेशन दिया गया है पहले से ही वहाँ है? क्या यह स्कैला परीक्षण की मूर्खता है?

+0

अगर आप टिप्पणी में पूर्ण classpath इस्तेमाल करने की कोशिश क्या होता है? – Yawar

+0

मैं अगर मैं – Jackie

उत्तर

-1

मैं FunSuite का उपयोग कर एक ही समस्या थी। जब मैं जुनीट की ओर जाता हूं तो यह काम करता है।

@RunWith(classOf[PowerMockRunner]) 
@PrepareForTest(Array(classOf[SomeStaticClass])) 
class MyTestClass { 

    @Before 
    def setUp { 
    PowerMockito.mockStatic(classOf[SomeStaticClass]) 
    Mockito.when(SomeStaticClass.getSomeObject(1)).thenReturn(new SomeObject(1)) 
    } 

@Test 
def someTestMethod { 
} 

आदि ...

+0

कर सकते हैं कि आज की कोशिश करेंगे लेकिन यह पता करने के लिए यह काम ScalaTest साथ – Vadim

+0

मैं एक ही बात करने की कोशिश की लेकिन स्केला परीक्षण परीक्षण नहीं मिल रहा होगा बनाने के लिए कैसे बहुत अच्छा होगा। – Jackie

+0

आह, मैं देखता हूं। यह मेरे लिए मुद्दा नहीं है, मैं इंटेलिजे आइडिया में जूनिट धावक के साथ परीक्षण चला रहा हूं। – Vadim

संबंधित मुद्दे