Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

possible improvement for issue #25 of using emma with powermock #46

Merged
merged 1 commit into from

1 participant

@luigi-agosti

No description provided.

@luigi-agosti luigi-agosti merged commit 63b7bf5 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
21 core/pom.xml
@@ -54,9 +54,30 @@
<version>1.4.12</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule</artifactId>
+ <version>1.4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-classloading-objenesis</artifactId>
+ <version>1.4.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.maven.plugin</groupId>
+ <artifactId>emma-maven-plugin</artifactId>
+ <version>1.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
View
29 core/src/test/java/com/novoda/imageloader/core/util/DirectLoaderTest.java
@@ -6,22 +6,23 @@
import java.io.InputStream;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.rule.PowerMockRule;
import android.graphics.Bitmap;
import com.novoda.imageloader.core.bitmap.BitmapUtil;
import com.novoda.imageloader.core.network.NetworkManager;
-//@RunWith(PowerMockRunner.class)
-//@PrepareForTest({ Bitmap.class })
+@PrepareForTest({ Bitmap.class })
public class DirectLoaderTest {
+ @Rule public PowerMockRule rule = new PowerMockRule();
+
private DirectLoader directLoader;
private NetworkManager networkManager;
private BitmapUtil bitmapUtil;
@@ -50,15 +51,15 @@ public void shouldReturnNullIfIsNotPossibleToGetAnInputStreamFromNetwrokResource
assertNull(directLoader.download(url));
}
-// @Test
-// public void shouldReturnBitmapFromHttpResource() {
-// String url = "http://www.google.com";
-// InputStream is = Mockito.mock(InputStream.class);
-// Mockito.when(networkManager.retrieveInputStream(url)).thenReturn(is);
-// Bitmap expectedBitmap = PowerMockito.mock(Bitmap.class);
-// PowerMockito.when(bitmapUtil.decodeInputStream(is)).thenReturn(expectedBitmap);
-// Bitmap actualBitmap = directLoader.download(url);
-// assertEquals(expectedBitmap, actualBitmap);
-// }
+ @Test
+ public void shouldReturnBitmapFromHttpResource() {
+ String url = "http://www.google.com";
+ InputStream is = Mockito.mock(InputStream.class);
+ Mockito.when(networkManager.retrieveInputStream(url)).thenReturn(is);
+ Bitmap expectedBitmap = PowerMockito.mock(Bitmap.class);
+ PowerMockito.when(bitmapUtil.decodeInputStream(is)).thenReturn(expectedBitmap);
+ Bitmap actualBitmap = directLoader.download(url);
+ assertEquals(expectedBitmap, actualBitmap);
+ }
}
Something went wrong with that request. Please try again.