A Kotlin Application that uses Guthub public API to show a list of repos name. It uses Retrofit and MockWebServer to mock apis.
Go to the app module build.gradle and add the following dependencies
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "com.squareup.okhttp3:okhttp:4.4.0"
androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.4.0"
androidTestImplementation 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
Go to the AndroidManifest.xml
and allow internet permission
<uses-permission android:name="android.permission.INTERNET"/>
In the AndroidManifest.xml
, make sure you add the name of the application you will use, in this instance it is GithubApp
.
android:name="GithubApp"
In the AndroidManifest.xml
, make sure you add the following or you may have issues using the MockTestRunner.
android:usesCleartextTraffic="true"
The api we are fetching is a normal list, an example of the type of API we are using link
[
{
"id": 132935648,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzI5MzU2NDg=",
"name": "boysenberry-repo-1",
"full_name": "octocat/boysenberry-repo-1",
"private": false,
"owner": {
"login": "octocat",
"id": 583231,
"node_id": "MDQ6VXNlcjU4MzIzMQ==",
"avatar_url": "https://avatars3.githubusercontent.com/u/583231?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
To run the unit tests locally.
./gradlew testdebugUnitTest
To run the ui tests locally, but first we need an emulator to be open.
./gradlew connectedCheck
Linter: we use the following linter link.
Uploading Artifacts: we use the following way to upload Artifacts, they allow you to persist data like test results after a job has completed, see the following documentation link.
Creating a Mock Server: we use a mock server with Postman to quickly test apis, to see how to create a mock server, see the following video link.
Fastlane: Fastlane allows us to automate our development and release process link.
App Center: App Center is used to distribute an app, making it very easy to test on a physical device by using a fastlane plugin link.
Npm: How to update a npm package.
- link.
Gemfile: How to update a Gemfile package.
- link.
How to manage releases in a repository link.
The following link provides very helpful information on Retrofit and mocking using MockWebServer.
- link.
The following link goes into leveling up your ui tests with MockWebServer
- link.
The following link provides a guide on consuming apis with Retrofit
- link.
The following link helps if you get the following error Failed to open QEMU pipe 'qemud:network': Invalid argument
.
- link.
The following link provides information if you failed to define the application in the manifest.
- link.
The following link provides information on how to convert from using Gson to Moshi.
- link.
The following link provides Moshi's official github which provides examples on how to use Moshi.
- link.
The following link provides info on Unresolved reference: kotlinx.
- link.