Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric: How can I unit test my fabfile?

In the previous project I was working on, our fabfile got out of control. While the rest of our project was well-tested, we didn't write a single test for our fabfile. Refactoring was scary, and we weren't confident a fabric command would work how we expected until we ran the command.

I'm starting a new project, and I'd like to make sure our fabfile is well-tested from the beginning. Obey the Testing Goat has a great article discussing some possible strategies, yet it has more questions than answers. Using fabtest is a possibility, although it seems to be dead.

Has anyone successfully unit tested their fabfile? If so, how?

like image 968
yndolok Avatar asked May 26 '14 04:05

yndolok


People also ask

Can you test an interface?

You can't. It has no implementation. You do want to test each and every class that implements this interface. To check that any class that implements the interface meets the expectations of the clients of that interface.

How interface is used in unit testing?

To test an interface with common tests regardless of implementation, you can use an abstract test case, and then create concrete instances of the test case for each implementation of the interface.

Is fabric an open source?

Software engineer and technical writer @ fabric. Open source e-commerce platforms provide a flexible and powerful framework for launching an e-commerce store, but contribute to the TCO of running and operating an online store.


Video Answer


1 Answers

  1. run your Fabfile task in a Docker instance

  2. use docker diff to verify that the right files were changed by the Fabfile.

This is still quite a bit of work, but it allows testing without excessive Fabfile modifications.

like image 51
johntellsall Avatar answered Sep 20 '22 12:09

johntellsall