Skip to content

Apadmi-Engineering/Mockzilla

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Repository files navigation

Mockzilla

Deployment

What is Mockzilla?

A solution for running and configuring a local HTTP server to mimic REST API endpoints used by your iOS, Android orKMMapplication.

The source code is written in Kotlin but is fully compatible with a Swift environment too!

Advantages

✅ Compile safe mock endpoint definitions.

✅ HTTP client agnostic.

✅ Works completely offline

✅ Entirely self-contained in your application's codebase.

Quick Start 🚀

Please see our quick start guide and full documentationhere.

Why's it useful? 🙌

Development servers go down, endpoints can be late being delivered or not exist at all! Mockzilla aims to easily provide a way of simulating your server from within your mobile application's codebase.

Why not use a hosted solution? ☁️

Hosted mocking solutions can be powerful mocking tools in many cases. They have their downsides:

  1. They can go down, Mockzilla works offline!
  2. There's no compile-time checking
  3. They require active maintenance with no compile-time safety if APIs change.

What makes it compile safe? 🖥️

By defining your mocks using the same model classes as are used for deserialization, changing them, means changing the mocks or we get compiler errors! 😎

Example usingkotlinx.serialization:

Existing networking models

@Serializable
data classHelloWorldResponse(valgreeting:String)

Mocking code

valmyEndpoint=EndpointConfiguration.Builder("hello-world")
.setPatternMatcher { uri.endsWith("hello-world") }
.setDefaultHandler {
MockzillaHttpResponse(
body=Json.encodeToString(
//Using existing models
HelloWorldResponse(greeting="Hello world!")
)
)
}

Important Note 🛑

Mockzilla is designed as a development and test toolonly.

Mockzilla shouldnever be used in production.Its traffic is unprotected and by nature of running a server on device, it can introduce security issues.

Do not ship it to production.