Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuous unit testing with Pydev (Python and Eclipse)

Is there a way to integrate background unit tests with the Pydev Eclipse environment?

My unit tests run well, but I would like to integrate them to run in the background based on source file changes (e.g. with nose) and to integrate the result back to Eclipse (I'm thinking big red X when tests fail with a console and trace log view).

No, a command prompt running nose on the side does not count.

I have had this Eclipse integration when developing RoR stuff.

Thanks,

Tal.

EDIT: Check out the new Pydev (1.6.4) http://pydev.org/manual_adv_pyunit.html

like image 610
Tal Weiss Avatar asked Jun 18 '09 22:06

Tal Weiss


People also ask

Is PyDev a Eclipse?

What is PyDev? PyDev is a Python IDE for Eclipse, which may be used in Python, Jython and IronPython development. It comes with many goodies such as: Django integration.

How do I create a PyDev project in Eclipse?

Create a new projectGo to File → New → PyDev Project to start a wizard. In the next window that appears, enter the name of your project and select "python" and 3.0"; as the type. Make sure "create default 'src' folder and add it to the pythonpath?" is selected. Click Finish.

How do I run code in PyDev?

Go to the menu: Alt + R + S + The number of the Run you wish (It can be Python, Jython, unit-test, etc). Note: if you were using unit-tests, you could use: Ctrl+F9 to run the unit-tests from the module (and even selecting which tests should be run -- and if Shift is pressed it's launched in debug mode).


2 Answers

This feature has been added to PyDev 2.0.1 with an option to relaunch the tests in the last test run whenever a python file change, with an additional option to rerun only the errors -- although it'll run the full test suite if no errors were found, as the idea is that you work through your errors and when all pass a final launch for the whole suite is done (then you can move on to another task).

The current nightly build has this feature incorporated.

Picture with new action

like image 78
Fabio Zadrozny Avatar answered Sep 23 '22 13:09

Fabio Zadrozny


Pydev does have some unit-test integration, but that's only as a run configuration...so...

This is not a very elegant way, but if you:

  1. Enable Project->Build Automatically
  2. In your project properties, add a new builder of type Program
  3. Configure it to run your tests and select 'during auto builds'

Then at least you will get something that outputs the test results to the console on resource saves.

like image 37
Henrik Gustafsson Avatar answered Sep 25 '22 13:09

Henrik Gustafsson