Is it possible to perform unittest tests via a web interface...and if so how?
EDIT: For now I want the results...for the tests I want them to be automated...possibly every time I make a change to the code. Sorry I forgot to make this more clear
If you're using PyCharm IDE, you can simply press ctrl+shift+F10 to run unittest module. Otherwise you can use command prompt to run this module. For example, we named the file for unit-testing as Basic_Test.py . So the command to run python unittest will be: $python3.
pytest supports running Python unittest -based tests out of the box. It's meant for leveraging existing unittest -based test suites to use pytest as a test runner and also allow to incrementally adapt the test suite to take full advantage of pytest's features.
PyUnit is an easy way to create unit testing programs and UnitTests with Python. (Note that docs.python.org uses the name "unittest", which is also the module name.)
EDIT:
This answer is outdated at this point:
The link to django-jenkins goes to a nice tutorial on how to use Jenkins with Django. I'll leave the text below since it still has some nice information.
As Bryan said, I'd use Hudson to schedule, run, and collect the test results. You can modify your tests to use xmlrunner.py (written by Sebastian Rittau), which will output your test results into an JUnit compatible XML file for Hudson.
Here's an example of how the test code would use xmlrunner:
import unittest
import xmlrunner
class TheTest(unittest.TestCase):
def testOne(self):
self.assertEquals(1, 1)
def testTwo(self):
self.assertEquals(2, 2)
def testThree(self):
self.assertEquals(3, 4)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TheTest)
xmlrunner.XMLTestRunner().run(suite)
Once you install Hudson, you'll create a new project for the source repository you're testing. You'll need to RTFM, but in a nutshell:
python test.py
).'TEST-*.xml' doesn't match anything
you can safely ignore it. It'll look something like this:
Once that's all done you'll be able to see test results for every time Hudson runs after check-in. It'll look something like this:
(source: snowpeaksoftware.com)
You also get more detailed pages like this page:
(source: snowpeaksoftware.com)
and this page:
(source: snowpeaksoftware.com)
You can use Hudson to schedule the tests to run whenever you check in code. Since Hudson is a web app, you can then see the results via the web (and/or publish them and/or email them to you or your team).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With