·

unit testing

Unit Test your custom module in Magento 2

Magento 2 comes with a great set of unit tests out-of-the-box. You can add these tests to your module as described by Ash Smith in this article, but that means you need to run your unit test with the –filter  attribute like so: This is great of course, but it still means the entire test read further ...

How to write unit tests for your websites’ JavaScript with Mocha

As some of you might know, I’ve already written a lot of posts about unit testing in PHP. But what about your JavaScript? That might require testing too. Especially when it comes to critical functions that involve complex operations. One road you could take to do this is use a headless browser and a testing read further ...

Generating dummy products for unit tests in Magento

I already wrote a number of posts about unit testing in Magento, but as with everything in Magento, some things are tricky to do, especially when it comes to unit tests. So the other day I wrote a module that needed to do certain actions according to the value of some product attributes. Needless to read further ...

How I run unit tests in Vagrant, in Jenkins

As some of you might know, I use Vagrant to setup my local environment, and Jenkins for my continuous integration. One major part of this setup is to automatically run tests after Jenkins is done building – and before it deploys the website to the production server. In this article I am going to share with read further ...

PHPUnit setup and teardown for tables

When you’re unit testing your code with PHPUnit, chances are that at some point you have to test some methods that involve manipulation on the database. Of course, you’ve written some test that validate the data in the database afterwards, and you might already have written a bootstrap that prepares the database for each testrun, but what read further ...

Unit testing frontend events in Magento

When you are creating unit tests for Magento and you want to test the events you’re dispatching you can use the following code to manually trigger your events: However, you’ll find that when you’re running this test, your event doesn’t get fired at all! That’s because this particular event (and many others) are fired read further ...

Ten days of Test Driven Development

  This is a story a of 2 developers who love their job. John is a passionate developer who likes to work punctual and precise. He loves test driven development because it gives him stability and guarantee in his work. He knows that it takes a bit more time and effort to setup, but he read further ...

Magento unit testing with specific customers

Sometimes you have the situation where you have to write unit tests for Magento that involves Magento customers. If – for example – you have some business logic that depends on certain customer- (or address-) attributes, you want to make sure your code works as expected before you’re deploying it to a live server. Unit testing read further ...

Unit testing Magento with the database

This year I want to dive more into unit testing in PHP. Writing good, test-driven code is important for the stability and guarantee of your project, but it also helps you – as a developer – sleep a little better at night. You might have seen earlier posts regarding unit testing in PHP in the past, read further ...

1 2