Skip to main content

3 posts tagged with "mock"

mock tag description

View All Tags

Mock vs. Fake vs. Spy: The Key Differences

· 7 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

While all are a form of test double-an object used to replace a real one during testing-their purpose and implementation differ significantly [1]. Understanding these differences is crucial for writing effective, maintainable tests.

Python Mocking Guide: External Dependencies, Test Doubles, and Pytest Best Practices

· 9 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

External dependencies are a major source of pain in unit testing. Network calls, persistent databases, and file systems are inherently slow, non-deterministic, and prone to environmental failures. Mocking these boundaries isolates your unit tests and delivers sub-second test execution suites.

However, over-mocking leads to brittle tests that pass while production code breaks. This guide provides a complete manual on Python test doubles: the architectural framework of when to mock, test double taxonomy (stubs, fakes, spies, mocks), hands-on unittest.mock examples for HTTP APIs, databases, and file systems, plus Pytest mocking pitfalls to avoid.

Create OpenAPI mock server

· 5 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Creating a mock server from a Swagger/OpenAPI file is a powerful way to decouple front-end and back-end development. It allows front-end developers to start building and testing their applications against a realistic API without waiting for the back-end to be completed.

Here's a step-by-step guide on how to set up a simple mock server using your OpenAPI specification file.