Java Mocking

Open-source Java projects categorized as Mocking

Top 11 Java Mocking Projects

  • Mockito

    Most popular Mocking framework for unit tests written in Java

  • WireMock

    A tool for mocking HTTP services

    Project mention: Fastify Meets WireMock: External Service Mocking | dev.to | 2024-02-13

    This article reveals how to integrate WireMock into Fastify with ease, enabling developers to effortlessly generate mock responses for external services. Join us as we explore the straightforward process of seamlessly integrating and optimizing Fastify applications using WireMock for enhanced testing capabilities.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • PowerMock

    PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.

  • Mockneat

    MockNeat - the modern faker lib.

  • JMockit

    Advanced Java library for integration testing, mocking, faking, and code coverage

  • castlemock

    Castle Mock is a web application that provides the functionality to mock out RESTful APIs and SOAP web services.

  • Hoverfly Java

    Java binding for Hoverfly

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

  • grpcmock

    A gRPC Java testing tool to easily mock endpoints of gRPC services for IT or Unit testing

  • unlogged-sdk

    Unlogged SDK for recording code execution

    Project mention: Show HN: Unlogged (YC S22) – open-source record and replay for Java | news.ycombinator.com | 2023-10-30

    Hello HN! Parth, and Shardul here. We have been building unlogged.io for the last 21 months. We started as a time travel debugger and pivoted to record and replay with assertions, mocking, and code coverage. You can save the replays in the form of a JSON and commit them to your git.

    Both Parth and I come from an e-commerce/payments background where production bugs meant heavy financial losses. Big billion days/Black Friday sales meant months of code freezes with low productivity. Before committing the code, we wanted to replay production traffic and know the breaking changes right away, like in sub-second. Kind of like unit+integration tests on steroids.

    So, we built an SDK that adds probes to the code in compile time. The SDK logs code execution, in detail.

    Git: https://github.com/unloggedio/unlogged-sdk

    We also built an IDE plugin that keeps monitoring code changes, hot reloads these changes, replays the relevant methods, and alerts on failing replays. It also lets developers call Java methods directly, mock downstream methods in run time, highlight code coverage in real-time, and show performance numbers for methods with inlay hints. (right above each method)

    Git: https://github.com/unloggedio/intellij-java-plugin

    We are excited to launch the first version of our product that replays with assertions + mocking + code coverage reports right inside the IDE.

    Link to our IntelliJ plugin: https://plugins.jetbrains.com/plugin/18529-unlogged/

    Record and Replay Demo: https://www.youtube.com/watch?v=muCyE-doEB0

    Define Assertions on Replay: https://www.youtube.com/watch?v=YKsi1p634-M

    Track Code Coverage: https://www.youtube.com/watch?v=NMmp954kfaU

    Generate JUnit Test Cases: https://www.youtube.com/watch?v=rTUmg5b1Z_Q

    Mocking when replaying: https://www.youtube.com/watch?v=O_aqU1u-Kmw

    Documentation: http://read.unlogged.io/

    Roadmap:

    1. Create a production logger

  • Retromock

    Java library for mocking responses in a Retrofit service.

  • mockito-object-injection

    Mockito Object Injection for JUnit5. Inject Strings and other Objects directly into Mocks without needing setters or constructor injection.

    Project mention: JEP 457: Class-File API for Parsing, generating, transforming | news.ycombinator.com | 2023-09-26

    This is pretty exciting... I've used them all libraries at this point in my career: CGLib, ASM, BCEL, ByteBuddy, Javassist, etc... each has its pluses and minuses. I've designed everything from profiling agents, to systems that pack decimals into EBCDIC and invoke COBOL programs on big IBM iron, to lightweight JIT compilers, all using these libraries.

    > In 2002, the visitor approach used by ASM seemed clever

    I couldn't agree more. The visitor pattern was very hard to explain/justify back then, and still difficult to explain to newbie programmers just entering the profession.

    Looking at the examples, I think this is going to be an official replacement for ASM, meaning it's going to be pretty low level. The use of streams pretty straightforward.

    If anyone from the JEP is reading this: I have two pieces of feedback!

    First, take some inspiration from the way CDI Portable Extensions work. This is probably the most delightful extension API I've ever used. The @Observe callbacks are super simple to explain to people and it's really easy to write extensions for the framework.

    Next, I wouldn't ignore the need for a higher-level API akin to ByteBuddy or Javassist. Sometimes I just want to write an interpreter or intercept a method call and thats it.

    For example in my Junit/Mockito extension https://github.com/exabrial/mockito-object-injection I need to intercept a call to the class under test in order to lazily inject dependencies at the last possible moment. While I certainly could do this with ASM, Javassist makes this fairly simple with it's MethodHandler api.

    Side note, it's a damn shame we don't have a mobile operating system that is JVM native :/ All this cool APIs simply never reach a huge number of devices.

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020). The latest post mention was on 2024-02-13.

Java Mocking related posts

Index

What are some of the best open-source Mocking projects in Java? This list will help you:

Project Stars
1 Mockito 14,515
2 WireMock 6,039
3 PowerMock 4,124
4 Mockneat 523
5 JMockit 458
6 castlemock 309
7 Hoverfly Java 165
8 grpcmock 137
9 unlogged-sdk 128
10 Retromock 66
11 mockito-object-injection 8
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com