Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Robolectricの @Configを共通化する方法
Search
えぐ
June 09, 2016
910
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Robolectricの @Configを共通化する方法
Android Testing Bootcamp #2の発表内容です
えぐ
June 09, 2016
More Decks by えぐ
See All by えぐ
KotshiからMoshi-codegenに 乗り換えた経緯
egugue
0
2.5k
Annotationを利用した現在時刻のテスト
egugue
0
900
エンジニアにしてもよいこと エンジニアからお願いしたいこと
egugue
0
180
コードで事前条件を表明する
egugue
3
3.9k
Backends for Frontends を適用した話
egugue
1
1.2k
FlexboxLayoutの紹介
egugue
2
350
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
520
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Transcript
Robolectricͷ @ConfigΛڞ௨Խ͢Δํ๏ Android Testing Bootcamp #2 2016/6/9
ࣗݾհ • ֎ࢁ ࣏༝ (@duane0728) • Ϡϑʔגࣜձࣾ • Yahoo JapanΞϓϦ୲
ҙ Robolectric3.1ΛͬͨʹͳΓ·͢
ҰൠతͳRobolectricͷ͍ํ
@RunWith(RobolectricGradleTestRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricGradleTestRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricGradleTestRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
• ςετΫϥεΛ࡞͢Δͨͼʹ@ConfigΛࢦఆ͢Δͷ໘ • ࢦఆͨͯ͢͠ͷ@ConfigͷઃఆΛมߋ͍ͨ͠߹ɺ ͯ͢ͷςετΫϥεΛमਖ਼ • @Configͷࢦఆํ๏͕มΘͬͯ͠·ͬͨ߹ɺ ͯ͢ͷςετΫϥεΛमਖ਼ 2ܥ͔Β3ܥͰมΘΓ·ͨ͠
@ConfigͷΛڞ௨Խ͍ͨ͠
ํ๏ - 1 ϑΝΠϧʹΓग़͢
ํ๏ - 1 • ެ͕ࣜఏڙ͍ͯ͠ΔΈΛར༻͢Δ http://robolectric.org/configuring/
sdk=23 constants=com.htoyama.robolectricconfigshare.BuildConfig robolectric.properties ͱ͍͏ϑΝΠϧΛ࡞
app/src/test/resources ʹϑΝΠϧΛஔ͘
@RunWith(RobolectricGradleTestRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricGradleTestRunner.class) public class ExampleUnitTest { @Test public void addition_isCorrect()
throws Exception { assertEquals(4, 2 + 2); } }
ํ๏ - 2 ςετϥϯφʔΛ࡞͢Δ
public class RobolectricCustomRunner extends RobolectricGradleTestRunner { private static final int[]
SDK = new int[]{23}; public RobolectricCustomRunner(Class<?> klass) throws InitializationError { super(klass); } @Override public Config getConfig(Method method) { Config c = super.getConfig(method); int[] sdkLevel = c.sdk().length == 0 ? SDK : c.sdk(); Class<?> constants = c.constants() == Void.class ? BuildConfig.class : c.constants(); return new Config.Implementation( sdkLevel, c.manifest(), c.qualifiers(), c.packageName(), c.abiSplit(), c.resourceDir(), c.assetDir(), c.buildDir(), c.shadows(), c.instrumentedPackages(), c.application(), c.libraries(), constants ); } }
public class RobolectricCustomRunner extends RobolectricGradleTestRunner { private static final int[]
SDK = new int[]{23}; public RobolectricCustomRunner(Class<?> klass) throws InitializationError { super(klass); } @Override public Config getConfig(Method method) { Config c = super.getConfig(method); int[] sdkLevel = c.sdk().length == 0 ? SDK : c.sdk(); Class<?> constants = c.constants() == Void.class ? BuildConfig.class : c.constants(); return new Config.Implementation( sdkLevel, c.manifest(), c.qualifiers(), c.packageName(), c.abiSplit(), c.resourceDir(), c.assetDir(), c.buildDir(), c.shadows(), c.instrumentedPackages(), c.application(), c.libraries(), constants ); } }
public class RobolectricCustomRunner extends RobolectricGradleTestRunner { private static final int[]
SDK = new int[]{23}; public RobolectricCustomRunner(Class<?> klass) throws InitializationError { super(klass); } @Override public Config getConfig(Method method) { Config c = super.getConfig(method); int[] sdkLevel = c.sdk().length == 0 ? SDK : c.sdk(); Class<?> constants = c.constants() == Void.class ? BuildConfig.class : c.constants(); return new Config.Implementation( sdkLevel, c.manifest(), c.qualifiers(), c.packageName(), c.abiSplit(), c.resourceDir(), c.assetDir(), c.buildDir(), c.shadows(), c.instrumentedPackages(), c.application(), c.libraries(), constants ); } }
public class RobolectricCustomRunner extends RobolectricGradleTestRunner { private static final int[]
SDK = new int[]{23}; public RobolectricCustomRunner(Class<?> klass) throws InitializationError { super(klass); } @Override public Config getConfig(Method method) { Config c = super.getConfig(method); int[] sdkLevel = c.sdk().length == 0 ? SDK : c.sdk(); Class<?> constants = c.constants() == Void.class ? BuildConfig.class : c.constants(); return new Config.Implementation( sdkLevel, c.manifest(), c.qualifiers(), c.packageName(), c.abiSplit(), c.resourceDir(), c.assetDir(), c.buildDir(), c.shadows(), c.instrumentedPackages(), c.application(), c.libraries(), constants ); } }
public class RobolectricCustomRunner extends RobolectricGradleTestRunner { private static final int[]
SDK = new int[]{23}; public RobolectricCustomRunner(Class<?> klass) throws InitializationError { super(klass); } @Override public Config getConfig(Method method) { Config c = super.getConfig(method); int[] sdkLevel = c.sdk().length == 0 ? SDK : c.sdk(); Class<?> constants = c.constants() == Void.class ? BuildConfig.class : c.constants(); return new Config.Implementation( sdkLevel, c.manifest(), c.qualifiers(), c.packageName(), c.abiSplit(), c.resourceDir(), c.assetDir(), c.buildDir(), c.shadows(), c.instrumentedPackages(), c.application(), c.libraries(), constants ); } }
@RunWith(RobolectricGradleTestRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricGradleTestRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricCustomRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricCustomRunner.class) @Config( sdk = 23, constants = BuildConfig.class ) public
class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
@RunWith(RobolectricCustomRunner.class) public class ExampleUnitTest { @Test public void addition_isCorrect()
throws Exception { assertEquals(4, 2 + 2); } }
·ͱΊ
• ࠓޙͷӡ༻ߟ͑ͯ@Configͷઃఆڞ௨Խͤ͞Δ • ڞ௨Խͤ͞Δํ๏2ͭ • ϑΝΠϧʹΓग़͢ • ςετϥϯφʔΛ࡞͢Δ
αϯϓϧίʔυ https://github.com/egugue/RobolectricConfigShare