Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the keyboard shortcut to run all unit tests in the current project in PyDev + Eclipse?

I know Ctrl + F9 runs a single file.

How to run them all?

If there is no such thing, how to bind one keyboard shortcut to it?

like image 597
Jader Dias Avatar asked Jan 31 '10 20:01

Jader Dias


People also ask

What key shortcut will test the main project in JUnit?

Press Alt+Shift+X,T to run the test (or right-click, Run As > JUnit Test).

How do I test a class in Eclipse?

In the Package Explorer area on the left side of the Eclipse window, right-click the class you want to test and click New → JUnit Test Case. A dialog box will pop up to help you create your test case. Make sure that the option at the top is set to use JUnit 4, not JUnit 3.

How do I run a unit test from command line in Python?

The command to run the tests is python -m unittest filename.py . In our case, the command to run the tests is python -m unittest test_utils.py .


2 Answers

Why not:

  • define a suite of tests, or a target in an ant script (like this one, at the bottom of the article), -and then associate a launch configuration (an external one for the ant script)?

You could then use a shortcut to that launch configuration (as in this thread).
One solution for that is to always launch the last application (F11 or Ctrl+F11 )

<target name="tests" depends="compile">
  <py-test pythonpath="${src.dir}" dir=".">
    <fileset dir="${src.dir}">
      <include name="**/*Test.py"/>
    </fileset>
  </py-test>
</target> 

Note: there are other ways to integrate unit testing with pydev, as shown in SO question Continuous unit testing with Pydev (Python and Eclipse)

like image 109
VonC Avatar answered Nov 03 '22 09:11

VonC


Click on a folder that contains tests in the pydev package explorer. Then the run menu option (which is not f9 for me but cmd+shift+F11 (OK I am on OSX but I suspect this would be ctrl+shift+f11 elsewhere) This runs all the tests it can find in subdirectories

To repeat you need to do as per VonC's answer

You could then use a shortcut to that launch configuration (as in this thread).
One solution for that is to always launch the last application (F11 or Ctrl+F11 )

like image 28
mmmmmm Avatar answered Nov 03 '22 08:11

mmmmmm