DEV Community

Cover image for PhpUnitGen, simplify the writing of your unit tests !
Paul Thébaud
Paul Thébaud

Posted on • Updated on

PhpUnitGen, simplify the writing of your unit tests !

This article is outdated. Check out the new one:


You are part of the very exclusive club of PHP developers and you inflict yourself swirls of copy/paste to satisfy PHPUnit?
Unit tests haunt you even in your nightmares?

PhpUnitGen has been designed to make your nights sweater and your apps better tested!

PhpUnitGen is an online or terminal development tool for generating your unit test skeletons for PHP code.

Why PhpUnitGen?

Like everyone else, I have to work to eat, and eat to work (even if development is a passion, huh).
I already had a taste of loop in the mouth, and my job was to test a PHP application.
What is more boring and uninteresting than recreating another skeleton of tests for an umpteenth PHP file ? A Formula 1 race maybe...

Starting from this postulate, I found myself wanting to "congratulate" the genius that would automatically generate all my skeletons of unit tests and thus save me a lot of time.

I modestly created this tool.
PhpUnitGen was born.

I then told myself that it might be better to take advantage of the time gained, rather than spend it in front of Netflix, and I published the tool in open source.

What is PhpUnitGen?

PhpUnitGen is a development tool, programmed in PHP7.1, which allows generating unit tests skeletons from a PHP source code.

The generated tests are written in PHP7.1 and to work with PHPUnit 6/7.

Here are some of PhpUnitGen features:

  • It automatically detects classes, traits or other formats and instantiates them appropriately.
  • It allows to generat tests automatically for getter/setter methods.
  • It proposes many PHP annotations allowing to create simple tests, mocks or instantiations of classes.

How to use it?

There are two ways to use PhpUnitGen.

Via the web application (open source): phpunitgen.io.

Via the Composer package that is used with a terminal (also open source): paulthebaud/phpunit-generator.

How to help improve PhpUnitGen ?

You can help improve PhpUnitGen by sending all your comments / bugs via Github issues.

You can also share the link of this article, the package or the web application!

Thank you for reading, and see you soon!

Top comments (2)

Collapse
 
cmmata profile image
Carles Mata

Great idea! I'll take a look and probably thank you a lot for this work 😉

Collapse
 
paulthebaud profile image
Paul Thébaud

Thank you a lot for your comment :D
Do not hesitate to let me know your thoughts about this project !