Posts

Showing posts with the label mock

Embedded Mocks and Hidden Contracts

Image
Testing is essential . Testing requires diversity, from integration to chaos , from your local machine to production . Writing tests not always is fun because sometimes is hard to write tests because not all contracts are good, and clean and went through a lot of thought processes. Is easy to blame the design, architecture, and even the implementation, but are we sure we are not missing anything? Something that is hard to test very likely will not be tested. Testability is a good property of any design or architecture sure. Making good solutions that are easy to test is a good thing. However, mocking is often taken for granted, meaning is seen as something that is just good and has no drawbacks, but that is not true. Everything has drawbacks. Integration tests are often seen as bad practices and people tend to lean toward unit tests instead. Just keep in mind Integration tests don't require mocks. Unit tests often require mocks to keep them isolated and cut off external dependencie...

Mock Server

Image
Mock Server is an interesting and useful testing solution. Mock Server allows HTTP and HTTP Tests and verifications. Mock Server supports Java and NodeJS. Mock Server requires requests to match expectations. It's not that different from a unit test from JUnit. However, Mock Server has the expectations in a central server and you could version those expectations as Json files for instances or use the standard API in order to create the with programmatic code in Java or NodeJS. So today I made a simple POC showing how we can use Mock Server, both with Java and JUNIT in an embedded fashion but also in standalone mode and using the dashboard UI mock server has. So Let's get started!

Testing the Impossible with PowerMock

Image
Testing is important. However, not all designs are testable and somethings we end up not being able to test things. A good design is always testable but not all testable code means you have good design. Sometimes we need to deal with old libs, old systems, 3rd party, or some active lib that is used a lot in your company that you cannot refactor. Not all tests have value however we need to be to test things which sometimes can be very very challenging.  Powermock helps us to test things that were impossible before.  Today I made a short video to show Powermock in action. So let's get started.