Audience
DevOps teams looking for a Unit Testing solution
About MockK
Mocking is a technique to make testing code readable and maintainable. In three consequent articles, I would like to show the basics, features, and quirks of the MockK library. It is a new open-source library (github repository) focused on making mocking in Kotlin great. Injection first tries to match properties by name, then by class or superclass. Check the lookupType parameter for customization. Properties are injected even if private is applied. Constructors for injection are selected from the biggest number of arguments to lowest.
Other Popular Alternatives & Related Software
Typemock
The easiest way to unit test. Write tests without changing your code! Even legacy code. Static methods, private methods, non-virtual methods, out parameters and even members and fields. Our professional edition is free for developers around the world. We also have paid support package. Improve your code integrity and deliver quality code. Fake entire object models with a single statement. Mock statics, private, constructors, events, linq, ref args, live, future, static constructors. Our suggest feature creates automated test suggestions suitable for your code. Our smart runner will run only your impact tests and get you super fast feedback. Our coverage feature displays your code coverage in your editor while you code.
Learn more about Typemock
JMockit
The toolkit is provided as a set of artifacts deployed to the Maven Central repository. It requires Java 7 or newer for test execution; tests must use JUnit or TestNG. For instructions on how to add the library to a Java project, see Running tests with JMockit. In this tutorial we examine the APIs available in the library, with the help of example tests (using Java 8). The central API - a single annotation - provides support for the automatic instantiation and initialization of the objects to be tested. Then we have the mocking API (also known as the "Expectations" API), intended for tests which use mocked dependencies. Finally, there is a small faking API (aka the "Mockups" API), which can be used for the creation and application of fake implementations that avoid the full cost of external components.
Learn more about JMockit
Mockito
Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with a clean & simple API. Mockito doesn’t give you hangover because the tests are very readable and they produce clean verification errors. Read more about features & motivations. Top 10 Java library across all libraries, not only the testing tools. In late 2013 there was an analysis made of 30.000 GitHub projects. Although Mockito reached number 9 in the main report, mockito-core and mockito-all are the same tool and therefore the factual position of Mockito is number 4, surpassing famous tools like Guava or Spring. Treat this study as an indicator of a big impact that Mockito makes every day on unit tests written in Java.
Learn more about Mockito
PowerMock
Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability. Often testability corresponds to good design, but this is not always the case. For example final classes and methods cannot be used, private methods sometimes need to be protected or unnecessarily moved to a collaborator, static methods should be avoided completely and so on simply because of the limitations of existing frameworks. PowerMock is a framework that extends other mock libraries such as EasyMock with more powerful capabilities. PowerMock uses a custom classloader and bytecode manipulation to enable mocking of static methods, constructors, final classes and methods, private methods, removal of static initializers and more. By using a custom classloader no changes need to be done to the IDE or continuous integration servers which simplifies adoption.
Learn more about PowerMock
Pricing
Starting Price:
Free
Free Version:
Free Version available.
Company Information
MockK
mockk.io
Other Useful Business Software
$300 Free Credits to Build on Google Cloud
Put your $300 in credit toward real workloads, then keep building with free monthly usage for 20+ products. No commitment and no charge until you upgrade.
Product Details
Platforms Supported
Windows
Mac
Linux
Training
Documentation
Support
Online
MockK Frequently Asked Questions
Q: What kinds of users and organization types does MockK work with?
MockK works with these users and organization types: Mid Size Business, Small Business, Enterprise, Freelance, Nonprofit, Government, and Startup.
Q: What languages does MockK support in their product?
MockK supports these languages: English.
Q: What kind of support options does MockK offer?
MockK offers support via online.
Q: What other applications or services does MockK integrate with?
MockK integrates with: JUnit and Kotlin.
Q: Does MockK have an API?
Yes, MockK has an API.
Q: What type of training does MockK provide?
MockK provides training in the form of documentation.
Q: How much does MockK cost?
Pricing for MockK starts at Free.