Mockito is a popular and powerful open source Java mocking framework. In order to achieve good unit tests, you need to make use of mocks and stubs. And that’s exactly what this talk will be about: What is a mock?
Tests should save our money and time. How is it that they often become the stumbling block and slow down the work? They fail every time you try to do some refactoring and are difficult to maintain ultimately increasing the cost of software maintenance.
Tomek Kaczanowski writes that the idea behind its “Bad Tests, Good Tests” book is “to present test code snippets and discuss ways of making them better.” To achieve this goal, he explores a large amount of code and tests to discuss all the issues that you can meet in your software testing activities.
In unit testing, you use mocks to simulate the behavior of other code parts in controlled ways. mock is a Python library for testing that allows you to replace parts of the system under test with mock objects and make assertions about how they have been used. mock has been integrated the Python standard library since version 3.3 under the name unittest.mock.
In my previous column PHP Unit Testing with PHPUnit,I showed how to set up PHPUnit and how to run a few simple tests. You should be able to test any function or method now that doesn’t rely on making calls out to other methods or functions – which is of course very few, as most applications are a complex combination of methods and, in PHP’s case, functions.
When you need to perform unit testing in an independent way, you use mock objects. Mock objects are simulated objects that mimic the behavior of real objects in controlled ways. In this excerpt of their book “Pragmatic Unit Testing in C# with NUnit”, Andy Hunt, Dave Thomas and Matt Hargett explain how to avoid coupling when you build your C# unit tests.
It is rather rare to have access to the software testing techniques used by a large project to maintain the quality of its code base. In this blog post, Jan Wloka, a member of the team behind IBM’s Rational Team Concert, presents the different techniques and tools used to control software evolution and to improve the quality of their code base.