Câu hỏi được gắn thẻ «powermock»

6
Mockito + PowerMock LinkageError trong khi chế độ lớp hệ thống
Tôi đã có một đoạn mã như vậy: @RunWith(PowerMockRunner.class) @PrepareForTest({Thread.class}) public class AllMeasuresDataTest { @Before public void setUp() throws Exception { } @Test public void testGetMeasures() { AllMeasuresData measure = new AllMeasuresData(); assertEquals(measure.getMeasures(), null); HashMap<String, Measure> map = new HashMap<String, Measure>(); measure.setMeasures(map); assertEquals(measure.getMeasures(), map); measure.setMeasures(null); assertEquals(measure.getMeasures(), null); } @Test public …



1
PowerMockito giả lập phương thức tĩnh đơn và đối tượng trả về
Tôi muốn mô phỏng một phương thức tĩnh m1 từ một lớp có chứa 2 phương thức tĩnh, m1 và m2. Và tôi muốn phương thức m1 trả về một đối tượng. Tôi đã thử cái sau 1) PowerMockito.mockStatic(Static.class, new Answer<Long>() { @Override public Long answer(InvocationOnMock invocation) throws Throwable { …

Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookie và Chính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.