Advertisement

Soft shake 2013 - make use of sonar on your mobile developments

rfelden
Oct. 29, 2013
Advertisement

More Related Content

Advertisement

Soft shake 2013 - make use of sonar on your mobile developments

  1. Make use of Sonar on your mobile developments - It’s easy and useful! October 26th, 2013 © OCTO 2013 Avenue du Théâtre 7 1005 Lausanne - SUISSE Tél : +41 (0) 21 312 94 15 Fax : +41 (0) 21 312 94 16 www.octo.ch 1
  2. Who We Are Romain Felden: Java / Android developer Cyril Picat: C++, iOS, Groovy/Grails developer OCTO Technology Jenkins Quality Dashboard iOS Android Maven Plugin Sonar Android Lint Plugin Quality Analysis Tools for Android Sonar Objective-C Plugin 2
  3. Agenda 1 QUALITY TOOLS ON MOBILE 2 SONAR PLUGINS PRESENTATION 3 HOW-TO & DEMO IOS 4 HOW-TO & DEMO ANDROID 5 CONCLUSION 3
  4. Sonar For the Uninitiated Manage quality of your software Across languages/platforms (> 20) Across projects Across time Across multiple axis/depths A web app for (re)viewing, a back-end for analysis 4
  5. Agenda 1 QUALITY TOOLS ON MOBILE 5
  6. Quality Tools on Mobile s s in kin k ) n Je en od V e5 J c L d n (X 2) 4) e (L for ) s o (Xco c i e e g o ge t od C od erag gin lan alys /cl ra e Bo bjXc Xc ov lu (C an nt v ( ( / p u o O t it nit e c de Lint ality nit ar g Uni M co e c Un U c U d d n o an C GT Co XC So slo O GH OC Co Xc OC Qu Cl ) e3 19xx 2007 2009 2011 M) 2012 2013 2008 First iOS SDK TESTS QUALITY
  7. Quality Tools on Mobile Sonar Objective-C Plugin sic a - Bics 1 .0. etr v0 m n sa t t L es es ge C u T eq - O .1 - era r ull 0.2 v0.3 cov v P int 7 2012/06 2013/07 2013/10 d
  8. Quality Tools on Mobile d n oi ugi r gin ) nd t-pl u ase ) pl ) r A lin le e e d fo t r leas oi mma t ol s oi d s e r n (fir t r nd EclE Li To ndr a a le s a id y n- Co ( tur a (la sty r e o ro alit ark e c n av aC n d Qu ob Emm he m C A J so C 2001 2004 2005 2009 2008 First Android SDK 2011 2012 2013
  9. Agenda 2 SONAR PLUGINS PRESENTATION 9
  10. Sonar Plugins Features Android Complexity Design Documentation Duplications Issues Size Tests √ √ √ √ √ (140) √ √ iOS X (*) X √ √ √ (58) √ (*) √ (*) integrated as issues (*) only LOC and files 10
  11. Sonar Plugin Architecture Sonar Sonar ObjC Platform Quality management Sonar Core gcovr oclint xcodebuild / xctool sonar-runner OCLint sensor xctool run-sonar.sh Build Cobertura sensor Measures/ Issues computation Surefire sensor Measures/ Issues integration Squid plugin Sonar Objective-C plugin 11
  12. Sonar Plugin Architecture Sonar Android Plugin Platform Quality management Measures/ Issues computation ant maven Sonar Android plugin PMD plugin JaCoCo plugin Checkstyle plugin Findbugs plugin Surefire plugin Squid plugin Measures/ Issues integration Sonar Core gradle Build 12
  13. Testing / Quality Tools Integration Kiwi UI Automation KIF Frank / UISpec UI Testing GTM BDD GHUnit √ Unit Testing ... √ X X X X X X X OCUnit / XCUnit OCLint Quality * * * * = in roadmap 13
  14. Testing / Quality Tools Integration Robolectric UIAutomator PMD Checkstyle Findbugs Lint Quality checks Robotium UI JUnit Unit and Integration Testing √ √ √ √ √ √ √ √ 14
  15. Agenda 3 HOW-TO & DEMO 15
  16. How-to Install Sonar, Sonar Runner and Sonar Objective-C plugin Install prerequisites (xctool, gcovr, oclint) Configure your project Run analysis 16
  17. Configure your project Copy run-sonar.sh in your Xcode project root folder and make it executable Copy sonar-project.properties in your Xcode project root folder Edit the sonar-project.properties file to match your Xcode iOS/MacOS project 17
  18. Demo https://github.com/dennisreimann/ioctocat (*) https://github.com/cyrilpicat/ioctocat 18
  19. sonar-project.properties #  Project  description sonar.projectKey=my-­‐project sonar.projectName=My  project sonar.projectVersion=1.0 sonar.projectDescription=Fake  description   #  Path  to  source  directories   sonar.sources=srcDir1,srcDir2   #  Xcode  project  configuration  (.xcodeproj   or  .xcworkspace) sonar.objectivec.project=myApplication.xcodeproj   sonar.objectivec.appScheme=myApplication sonar.objectivec.testScheme=myApplicationTests 19
  20. Run it! >  ./run-­‐sonar.sh 20
  21. Jenkins Quality Dashboard Almost feature complete No code checks Timeconsuming, error prone and intrusive Weak reporting and configuration 21
  22. How-to using maven Install Sonar and Sonar Android plugin Add maven profile(s) to your module(s) Connect ADB in root mode Run analysis 22
  23. Maven structure Parent module Application module Library module Integration testing module 23
  24. Demo Morse Flash https://github.com/jayway/maven-android-plugin-samples 24
  25. Maven profiles parent module <profile> <id>sonar</id> <modules> <module>morse-lib</module> <module>morseflash-app</module> <module>morseflash-instrumentation</module> </modules> <properties> <sonar.profile>Android Lint</sonar.profile> <sonar.jacoco.excludes>*test*</sonar.jacoco.excludes> <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath> <sonar.jacoco.reportPath>jacoco.exec</sonar.jacoco.reportPath> <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> <sonar.skippedModules>morseflash-instrumentation</sonar.skippedModules> <sonar.exclusions>**/org/jacoco/**</sonar.exclusions> <jacoco.version>0.6.2.201302030002</jacoco.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.jacoco</groupId> <artifactId>org.jacoco.agent</artifactId> <version>${jacoco.version}</version> <classifier>runtime</classifier> </dependency> </dependencies> </dependencyManagement> <build> <pluginManagement> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> </plugin> </plugins> </pluginManagement> </build> </profile> 25
  26. Maven profiles application module (includes unit testing) <profile> <id>sonar</id> <dependencies> <dependency> <groupId>org.jacoco</groupId> <artifactId>org.jacoco.agent</artifactId> <classifier>runtime</classifier> <scope>compile</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>instrument-classes</id> <goals> <goal>instrument</goal> </goals> <configuration> <excludes> <exclude>*test*</exclude> <exclude>*/test/*</exclude> </excludes> </configuration> </execution> <execution> <id>restore-instrumented-classes</id> <phase>package</phase> <goals> <goal>restore-instrumented-classes</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <configuration> <test> <coverage>true</coverage> <createReport>true</createReport> </test> </configuration> <extensions>true</extensions> </plugin> </plugins> </build> </profile> 26
  27. Maven profiles integration testing module <profiles> <profile> <id>sonar</id> <build> <plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <configuration> <dex> <!-- Required for EMMA --> <noLocals>true</noLocals> </dex> <test> <coverage>true</coverage> <createReport>true</createReport> </test> </configuration> <executions> <execution> <id>pull-coverage</id> <phase>post-integration-test</phase> <goals> <goal>pull</goal> </goals> <configuration> <pullSource>/data/data/com.simpligility.android.morseflash/files/coverage.ec</pullSource> <pullDestination>${project.basedir}/../morseflash-app/target/jacoco-it.exec</pullDestination> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> 27
  28. Run it! >  mvn  -­‐P  sonar  clean  install >  mvn  -­‐P  sonar  sonar:sonar 28
  29. Agenda 5 CONCLUSION 29
  30. Why Use Sonar? Mobile projects are small and short, is it applicable? Three typical uses cases: Small and short projects Assessments Bigger projects (there are!) 30
  31. Stay in touch! Objective-C plugin: https://github.com/octotechnology/sonar-objective-c Sonar Android Lint plugin: https:// github.com/SonarCommunity/sonar-android Quality Analysis Tools for Android: https://github.com/stephanenicolas/QualityTools-for-Android http://fr.slideshare.net/jeromevdl/droidconparis-2013 31
  32. Questions/Answers © OCTO 2013 Avenue du Théâtre 7 1005 Lausanne - SUISSE Tél : +41 (0) 21 312 94 15 Fax : +41 (0) 21 312 94 16 www.octo.ch 32
Advertisement