Coder Social home page Coder Social logo

android-pipeline's Introduction

Android Pipeline

1 - Create Android application following Android Studio Wizard, you may choose any prefered language (Android or Kotlin)

Basics of Build

1 - Run the Gradle build task: ./gradlew build

Basics of Unit Testing

1 - Open "ExampleUnitTest" file and make the test fail

class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        Assert.assertEquals(5, 2 + 2)
    }
}

2 - Run the Gradle test task: ./gradlew test

If there is some unit test failing it will appear in your console:

> Task :app:testDebugUnitTest FAILED

com.tw.pipeline.ExampleUnitTest > addition_isCorrect FAILED
    java.lang.AssertionError at ExampleUnitTest.kt:9

2 tests completed, 1 failed


FAILURE: Build failed with an exception.

3 - Fix the unit test that you have modified, and run the command again. Just a Build Succeed will appear:

BUILD SUCCESSFUL in 5s
38 actionable tasks: 6 executed, 32 up-to-date

If you want to run your tests for only one build type (this can be important for a large test suite) you can use ./gradlew testDebug or ./gradlew testRelease.

5 - Open the generated reports:

When you run this task some tests reports are generated, it is placed in: "app/build/reports/tests/testDebugUnitTest/index.html" "app/build/reports/tests/testReleaseUnitTest/index.html"

Basics of Android UI testing

1 - Be connected with some Android device (real or emulator)

2 - Open "ExampleInstrumentedTest" file and make the test fail

@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
   @Test
   fun useAppContext() {
       // Context of the app under test.
       val appContext = InstrumentationRegistry.getTargetContext()
       assertEquals("package.name.to.fail", appContext.packageName)
   }
}

3 - Run the Gradle test task: ./gradlew connectedAndroidTest

If there is some unit test failing it will appear in your console:

Starting 1 tests on Nexus_5_API_27_PLAY(AVD) - 8.1.0ctedAndroidTest 

com.tw.pipeline.ExampleInstrumentedTest > useAppContext[Nexus_5_API_27_PLAY(AVD) - 8.1.0] FAILED 
        org.junit.ComparisonFailure: expected:<[different.name.of.packag]e> but was:<[com.tw.pipelin]e>
        at org.junit.Assert.assertEquals(Assert.java:115)
Starting 1 tests on Moto E (4) - 7.1.1

com.tw.pipeline.ExampleInstrumentedTest > useAppContext[Moto E (4) - 7.1.1] FAILED 
        org.junit.ComparisonFailure: expected:<[different.name.of.packag]e> but was:<[com.tw.pipelin]e>
        at org.junit.Assert.assertEquals(Assert.java:115)

FAILURE: Build failed with an exception.

4 - Fix the UI test that you have modified, and run the command again. Just a Build Succeed will appear:

Starting 1 tests on Nexus_5_API_27_PLAY(AVD) - 8.1.0

BUILD SUCCESSFUL in 26s
52 actionable tasks: 1 executed, 51 up-to-date

If you want to run your tests for only one build type (this can be important for a large test suite) you can use ./gradlew connectedDebugAndroidTest or ./gradlew connectedReleaseAndroidTest.

5 - Open the generated reports:

When you run this task some tests reports are generated, it is placed in: "app/build/reports/androidTests/connected/index.html"

Fastlane Install

Setup Google Play Console

Lint

If you want to analyze the source code with some lint tool, the Android Studio provides you a native solution thought Gradle. It automatically generates reports and you can integrate this task in your pipeline to make your job fail when there is some issue found.

1 - ./gradlew lint

When you run this task some lint reports are generated, it is placed in: "/app/build/reports/lint-results.html" "/app/build/reports/lint-results.xml"

If you want to break your build on any lint warning found. Just open build.gradle file and add:

lintOptions {
    warningsAsErrors true   
}

Code Format

android-pipeline's People

Contributors

gcherubini avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.