Coder Social home page Coder Social logo

tfrommen / testable-code Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 2.0 39 KB

Example code for the talk "How (Not) to Write Testable Code" at WordCamp Nuremberg, 2016.

Home Page: https://slides.tfrommen.de/testable-code/

License: MIT License

JavaScript 28.74% PHP 71.26%
testability unit-testing

testable-code's Introduction

How (Not) to Write Testable Code

This repository contains example code for the according talk at WordCamp Nuremberg, 2016.

Unit Test Examples

The first part of the talk is about unit testing. After a short summary, you can see several unit test examples. This repository includes the complete and fully documented versions of the presented PHP unit tests as well as the respective JavaScript unit tests.

Running the Tests

You want to run the tests yourself? Here's how:

JavaScript

In order to run the JavaScript tests, you have to install the required npm packages first.

Using Yarn:

$ yarn && yarn run test

Using npm:

$ npm i && npm run test

PHP

In order to run the PHP tests, you have to install the required Composer packages first.

$ composer install && vendor/bin/phpunit

Bad Practices

The second and main part of the talk then is about code examples that are either hard to test, or not testable at all. As with the unit test examples, this repository also includes the bad practice PHP code and JavaScript code examples.

Since only presenting bad (i.e., hard-to-test) code doesn't do any good, this repository also includes improved versions of the code. For each of the code examples, you can find an according pull request. By means of the diff view, you can easily compare the original and the improved code.

Feel free to fork this repository, and work on possible tests, if you like.

Changelog

Changelog.

License

Copyright (c) 2016 Thorsten Frommen

This code is licensed under the MIT License.

testable-code's People

Contributors

tfrommen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ahmedattia85

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.