How to automatically run Python unittests in Eclipse

this time I will share tips on how to python Eclipse. Create a python script to run the unittests
ahmadnurhadirmw - this time I will share tips on how to python Eclipse. Create a python script to run the unittests as follows (the first line is important):
#!/usr/bin/python

import unittest

from nose.plugins.collect import TestSuite
    
if __name__ == "__main__":
    testsuite = unittest.TestLoader().discover('.')
    unittest.TextTestRunner(verbosity=2).run(testsuite)
Change the permissions of the script to make it executable as follows:
chmod +x /path/to/python_script.py
In Eclipse, right-click on the project and go to "properties"

Click on the "builders" tab and create a new builder

In "location" type /path/to/python_script.py and in "working directory" browse the workspace to the folder where the script is.

Under "build options", select "During auto builds" and apply these changes.

Under the "project" menu make sure "build-automatically is selected"

Now when you save your unittests should run and output for example
Ran 22 tests in 0.001s

OK

Post a Comment

0 Comments