1
テストするカスタムフォントがあり、Android Testを使用したくないので、AssetManagerを取得するにはエミュレータ/デバイスが必要です。だから私はRobolectricを使用することを考えたが、私はこの奇妙な問題(ユニットテストで示される)発生します。私が使用しているRobolectric:アセットから作成したときにタイプフェースオブジェクトがすべて同じです
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 25, shadows = ShadowMultiDex.class)
public class CustomFontUnitTest {
@Test
public void typefacesShouldNotBeIdentical() throws Exception {
AssetManager assets = RuntimeEnvironment.application.getAssets();
Typeface avenirLight = Typeface.createFromAsset(assets, "fonts/avenir_lt_35_light.ttf");
Typeface avenirLightOblique = Typeface.createFromAsset(assets, "fonts/avenir_lt_35_light_oblique.ttf");
assertThat(avenirLight, not(equalTo(avenirLightOblique)));
}
}
を:
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'org.robolectric:robolectric:3.2.2'
testCompile 'org.robolectric:shadows-multidex:3.2.2'
しかし、私はテストを実行し、書体オブジェクトを
java.lang.AssertionError:
Expected: not <[email protected]>
but: was <[email protected]>
Expected :not <[email protected]>
誰かが私が間違っていると考えている人はいますか?
Robolectric githubプロジェクトにバグを書く –
Robolectric github:https://github.com/にバグを投稿しました。 robolectric/robolectric/issues/2895 – Rule