Skip to content

Latest commit

 

History

History
72 lines (48 loc) · 2.4 KB

README.md

File metadata and controls

72 lines (48 loc) · 2.4 KB

xUnit Environments for Various Languages

So you want to hold a Dojo, but you don't want to spend half the time writing all the testing boilerplate and figuring out all the dependencies necessary to even write tests, let alone run them? Wouldn't you love for the tests to run automatically when a file is saved? Well, you're in luck.

Prerequisites

Testing Languages

Installation

  1. Install grunt-cli globally: npm install -g grunt-cli
  2. Install this repository: git clone https://github.com/orlandodojo/xUnit_Environments.git
  3. Hop on into the new directory: cd xUnit_Environments/
  4. Install the Javascript dependencies: npm install

You now have enough to start testing Javascript, at least. If you have Python or Ruby installed, you probably have enough to get started with both of those, as well. In order to write tests in PHP, you'll need to install PHPUnit. For that, you should consider installing via Composer: composer install should do the trick.

Write Some Tests!

Each folder contains a single main and test file; you can imagine what those are for. If you can't, here's an example for Python:

## python/main.py

class YourAwesomeSolution(object):
    pass

Note that test.py comes with some boilerplate to make it easy to just start writing tests:

## python/test.py

from main import *
import unittest

class Test ( unittest.TestCase ):
    def setUp ( self ):
        pass

    def test_something ( self ):
        self.assertFalse(True)


if __name__ == '__main__':
    unittest.main()

Change test_something() into your first test and run the tests with the supplied Grunt task: grunt shell:test_py

Wait, didn't you promise some auto-magic...?

Yes, well, for the very lazy, you can run the watch Grunt task, which is preconfigured to watch the source files for changes and run the appropriate tests for you. It's also configured to be the default task, so you can also just run grunt. If you want fancier notifications than CLI, feel free to open PRs!

Primarily wired together by @al-the-x (twitter)