awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
powermock avatar

powermock/powermock

0
View on GitHub↗
4,174 stars·575 forks·Java·Apache-2.0·27 views

Powermock

Powermock is a Java mocking framework and unit testing tool that uses bytecode manipulation to mock static methods, final classes, and private constructors. It includes a Java agent instrumentation tool and a reflection-based testing utility to bypass encapsulation and modify class behavior at runtime.

The project distinguishes itself by providing the ability to intercept the instantiation of objects via the new keyword and simulate the behavior of core Java system classes and native methods. It can override final modifiers on classes and methods and bypass signature restrictions for classes contained within signed archives.

The toolset covers broad capability areas including private member mocking, object construction verification, and the suppression of static initializers and constructors. It also provides reflection utilities for private state management and integrates with JUnit through specialized rules and runners.

Integration is supported for modular architectures such as OSGi and various external test execution frameworks.

Features

  • Java Unit Testing - Implements a specialized unit testing framework for Java that isolates code by mocking static methods and final classes.
  • Bytecode Instrumentation Agents - Includes a runtime agent that injects bytecode transformations to modify system classes and bypass runtime environment locks.
  • Runtime Instrumentation Agents - Injects bytecode transformations at runtime to modify system classes and bypass restricted environment locks.
  • Bytecode Manipulation - Rewrites class bytes during loading to remove modifiers and intercept static or private method calls.
  • Java Bytecode Manipulation - Provides advanced capabilities to modify compiled Java class bytes at runtime to override language restrictions and bypass encapsulation.
  • Method Interception Proxies - Implements a mocking engine that reroutes method calls to a proxy handler to return predefined values.
  • Constructor Interception - Intercepts the Java 'new' keyword to return mock instances instead of real objects during class instantiation.
  • Mocking Frameworks - Provides a comprehensive Java mocking framework utilizing bytecode manipulation to isolate static methods, final classes, and private constructors.
  • Partial Mocks - Implements test doubles that selectively execute original class logic while overriding specific methods.
  • Private Member Mocks - Overrides private or final methods to verify internal behavior without altering source code visibility.
  • Private Constructor Mocks - Bypasses private constructor restrictions to enable the creation of mock objects for classes with limited instantiation.
  • Static Member Mocks - Uses bytecode instrumentation to mock static methods and object instances to isolate tests from real implementations.
  • Private Method Stubs - Intercepts calls to private methods to isolate the unit under test from its internal dependencies.
  • System Class Mocking - Intercepts calls to core runtime system classes and native methods typically locked by the JVM.
  • Legacy Code Testing - Enables testing of old Java codebases by suppressing static initializers and intercepting internal object construction without source changes.
  • Private Member Access - Provides utilities to retrieve or modify private fields and methods from external classes via reflection.
  • Startup Agent Bootstrapping - Loads the project environment as a system agent to resolve classloading conflicts during JVM startup.
  • Private Constructor Invocations - Creates instances of classes with private constructors by invoking them through reflection.
  • Reflection-Based State Inspection - Uses language reflection to get or set private field values and verify object state.
  • Reflection Utilities - Includes reflection-based utilities for invoking private methods and accessing internal object state.
  • System Class Mocking - Simulates the behavior of core Java system classes and native methods typically locked by the JVM runtime.
  • Encapsulation Bypasses - Uses reflection to access and modify private members of a class without changing source code visibility.
  • Field Initialization Suppressions - Prevents specific member fields from being initialized during object instantiation.
  • JUnit Rule Integrations - Provides specialized JUnit rules and runners to integrate advanced bytecode mocking into standard Java test suites.
  • Member Field Resets - Restores member field values to their defaults after execution to ensure a clean state between tests.
  • Method Executions Suppressions - Disables specific method calls or code blocks during tests to avoid side effects and external dependencies.
  • Method Execution Suppressions - Blocks specific methods from executing and returns default values to bypass logic hindering unit tests.
  • Initializer Suppressions - Prevents the execution of static initializers and constructors during object creation to avoid side effects.
  • Construction Verification - Provides capabilities to verify that a specific class was instantiated with the expected arguments during test execution.
  • Private Method Invocations - Provides the ability to execute and verify logic within private methods and fields using Java reflection.
  • Signed Class Mocking - Bypasses signature verification to mock classes contained within signed archives.
  • Final Member Mocks - Overrides final modifiers on classes and methods to control their behavior during test execution.
  • Method Interception Spies - Creates spies of existing objects to mock specific methods while preserving the original behavior of others.
  • Testing Frameworks - Mocks static methods, constructors, and private methods.

Star history

Star history chart for powermock/powermockStar history chart for powermock/powermock

How this analysis was created: This summary and feature list were written by an AI model that read the project's README and public documentation pages. Each feature links to the documentation it came from; stars, license and language come straight from the GitHub API. The model does not read the source code, and the analysis is refreshed when the project is re-analysed. Learn more on our About page.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Open-source alternatives to Powermock

Similar open-source projects, ranked by how many features they share with Powermock.
  • mockk/mockkmockk avatar

    mockk/mockk

    5,747View on GitHub↗

    MockK is a Kotlin test double framework that creates mocks, spies, and relaxed mocks for unit testing, with support for final classes, static methods, and coroutines. It functions as a bytecode instrumentation library that modifies compiled class files at load time to intercept constructors, final methods, and static functions without source changes, and also provides dedicated libraries for constructor mocking and coroutine mocking. The framework is designed specifically for Kotlin, handling Kotlin-specific constructs like extension functions, singletons, and suspend functions. MockK disting

    Kotlinargument-matcherschain-callshacktoberfest
    View on GitHub↗5,747
  • mockito/mockitomockito avatar

    mockito/mockito

    15,432View on GitHub↗

    Mockito is a Java mocking framework and JUnit testing library used to create simulated objects and stub method calls to isolate components during unit tests. It functions as a dynamic proxy generator and bytecode instrumentation tool, allowing for the creation of runtime substitutes that mimic the behavior of real classes. The framework distinguishes itself by providing the ability to mock final classes and methods, bypassing standard language restrictions through bytecode modification. This capability enables the testing of legacy code that lacks interfaces. The toolset covers behavioral mo

    Java
    View on GitHub↗15,432
  • raphw/byte-buddyraphw avatar

    raphw/byte-buddy

    6,856View on GitHub↗

    Byte Buddy is a runtime code generation and bytecode manipulation library for Java. It provides a fluent API for creating and modifying Java classes during execution, enabling developers to define class structures, methods, and fields programmatically without requiring a compiler or direct bytecode assembly. The library supports agent-based class transformation, allowing loaded classes to be modified during JVM startup or runtime through a Java agent that intercepts class loading. It offers bytecode-level method interception for fine-grained control over method behavior, annotation-based code

    Javabyte-codedynamic-proxyinstrumentation
    View on GitHub↗6,856
  • sinonjs/sinonsinonjs avatar

    sinonjs/sinon

    9,753View on GitHub↗

    Sinon is a JavaScript test double library and mocking framework used to isolate code and verify behavior during unit testing. It provides a collection of spies, stubs, and mocks that replace real function implementations and object methods with controlled substitutes. The project includes a specialized fake timer library for overriding the system clock, allowing the simulation of time progression to trigger timeouts and intervals without waiting for real-time delays. It also features a test sandbox mechanism to group multiple fakes together, ensuring the original state is restored between tes

    JavaScript
    View on GitHub↗9,753
See all 30 alternatives to Powermock→

Frequently asked questions

What does powermock/powermock do?

Powermock is a Java mocking framework and unit testing tool that uses bytecode manipulation to mock static methods, final classes, and private constructors. It includes a Java agent instrumentation tool and a reflection-based testing utility to bypass encapsulation and modify class behavior at runtime.

What are the main features of powermock/powermock?

The main features of powermock/powermock are: Java Unit Testing, Bytecode Instrumentation Agents, Runtime Instrumentation Agents, Bytecode Manipulation, Java Bytecode Manipulation, Method Interception Proxies, Constructor Interception, Mocking Frameworks.

What are some open-source alternatives to powermock/powermock?

Open-source alternatives to powermock/powermock include: mockk/mockk — MockK is a Kotlin test double framework that creates mocks, spies, and relaxed mocks for unit testing, with support… mockito/mockito — Mockito is a Java mocking framework and JUnit testing library used to create simulated objects and stub method calls… raphw/byte-buddy — Byte Buddy is a runtime code generation and bytecode manipulation library for Java. It provides a fluent API for… sinonjs/sinon — Sinon is a JavaScript test double library and mocking framework used to isolate code and verify behavior during unit… btraceio/btrace — btrace is a JVM dynamic tracing tool and performance profiler used for injecting safe instrumentation scripts into a… rspec/rspec-mocks — This project is a Ruby unit testing tool designed for dependency isolation and behavioral contract verification. It…