8000 GitHub - rebecaalbuquerque/android-fake-server: A library that facilitates the creation of a fake server for testing and development purposes. · GitHub
[go: up one dir, main page]

Skip to content

rebecaalbuquerque/android-fake-server

Repository files navigation

Fake Server

Imagine during the development of your app being able to configure the response of your endpoints quickly, without having to worry about setting up software like Mockoon or Flipper.

Fake Server is a library for Android development that facilitates creating a fake server for testing and development purposes. It allows you to register fake responses for different URLs and return these responses during testing or development.

Installation

Add the JitPack repository to your build.gradle (at the project level):

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency to your build.gradle (at the module level):

dependencies {
  implementation 'com.github.rebecaalbuquerque:android-fake-server:$version'
}

Usage

Initialize FakeServer

Preferably, initialize it in the Application for a global configuration.

class MyApplication: Application() {

    override fun onCreate() {
        super.onCreate()
        FakeServer.initialize(this)
    }
}

(Optional) Register a fake response:

FakeServer.registerResponse(
  endpoint = "path-to-endpoint",
  response = """
      {
          "id": 1,
          "name": "test"
      }
  """
)

Create your service layer