powermock

    0熱度

    3回答

    我在服務類有成員: @Value("${dynamodb.aws.region}") private String region; 使用時對生產的類,在使用Spring從我.properties文件被注入的值。 然後,在測試模式下,我需要檢查這個代碼: @Override public void init() { if (StringUtils.isEmpty(region)){

    4熱度

    1回答

    我有以下方法 public ResultScanner getScanner(Scan scan) { Table table = getTableInstance("Sampletable"); return table.getScanner(scan); } 爲此,我寫了下面的JUnit測試代碼 Connection mockconnection = PowerMoc

    0熱度

    1回答

    使用Spring啓動啓動器測試來測試我的應用程序,但我使用的是第三方庫。讓我們假設我們有一個TRequest類,它有一些構造函數,我想模擬並存儲該構造函數以返回結果。 @SpringBootTest @RunWith(SpringRunner.class) @PrepareForEverythingForTest public class TestClass { @MockBean T

    0熱度

    1回答

    我有一個非常大的項目,並在某些時候開發人員開始注意到,如果他們嘗試在intellij中運行/調試PowerMock驅動的測試,他們會得到以下錯誤: java.lang.NoClassDefFoundError: org/powermock/core/transformers/impl/MainMockTransformer FATAL ERROR in native method: proces

    1熱度

    3回答

    我有一個我想測試的Spring Batch的文件處理程序。 SpringApplication.run()是,我想驗證傳遞給它的參數的靜態方法。 這是否意味着我需要下井PowerMock路徑或者是有什麼在springframework的,使我對此進行測試? public File handleFile(File file) { // Start the Batch Process an

    0熱度

    1回答

    的Java供應商界面我有模擬與Powermockito一個https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java,它的工作原理之前,但因爲代碼chanage,並添加如下代碼: NetworkModul

    0熱度

    1回答

    我想用EasyMock的-powermock嘲笑以下方法鏈, OtherClass oc = SampleClass.getInstance().getSampleMethod(new StringReader("ABC"); 的getInstance()是一個單方法。 getSampleMethod()是一個公共方法。 當我嘗試使用expect/andReturn變爲null時。

    1熱度

    1回答

    我想出來的例子來嘲笑以下鏈接 https://github.com/powermock/powermock/wiki/mockconstructor 雖然Junit的運行通行證但PersistenceManager的代碼覆蓋率報告提供了一個構造函數類是百分之零。 這是因爲@PrepareForTest(PersistenceManager.class)沒有這行代碼失敗。 如何模擬構造函數調用並獲得

    -3熱度

    2回答

    我試圖嘲笑來自我的課程的另一個類的實例的調用。我看到的問題是,當我運行我的測試時,看起來我的模擬對象不會被真實對象所取代。我在這裏舉了一個簡單的例子來解釋這個案例。在這裏,我想打印tada而不是的默認方法this is awsome。我已經把我的代碼放在下面的鏈接中供參考,請讓我知道我做錯了什麼,如果有的話。 https://gist.github.com/anonymous/1eab366c60

    4熱度

    1回答

    public static ResponseBean call(Bean bean) throws Exception { // statements... IgnoreCall.ignoreMethodCall(bean); // statements... // return } 通過上面的代碼段中,是有可能測試IgnoreCall.ignore