How to run only one test in TestCase in NetBeans PHP? - netbeans

I can run all tests for current file, but how to run only one test?

There are buttons in the Test Results pane to rerun only the tests that failed during the previous run, but I know of no way to run a single test. Right-click a test in that same pane to see if you get an option to run it alone. I'm not at work to test out that theory.

There is a way to do it netbeans: Click Window -> Ide Tools -> Terminal and type:
phpunit --filter '/::testName$/' MyTest.php
Then click Enter.
as far as I know there is no button or something in Netbeans that does that. So using terminal seems like the easiest way. It still is quite convenient though, because it should remember the history and later on you can just copy paste the test name.
Note that you may have to navigate to the test folder first or specify path to your Test file first in case Netbeans terminal doesn't open in your test project folder already

Related

How do I get the command-line for an Eclipse run configuration?

I have several JUnit run configurations in Eclipse that I need to replicate on the command-line in order to use a third-party analysis tool. So far I've just been writing the command-line manually by looking at the run configuration and writing the appropriate classpath and command-line arguments.
Eclipse's run configurations (normal, JUnit, or other) must ultimately boil down to a command-line anyway, so how and where do I find that?
I found a solution on Stack Overflow for Java program run configurations which also works for JUnit run configurations.
You can get the full command executed by your configuration on the
Debug tab, or more specifically the Debug view.
Run your application
Go to your Debug perspective
There should be an
entry in there (in the Debug View) for the app you've just executed
Right-click the node which references java.exe or javaw.exe and
select Properties In the dialog that pops up you'll see the Command
Line which includes all jars, parameters, etc
You'll find the junit launch commands in .metadata/.plugins/org.eclipse.debug.core/.launches, assuming your Eclipse works like mine does. The files are named {TestClass}.launch.
You will probably also need the .classpath file in the project directory that contains the test class.
Like the run configurations, they're XML files (even if they don't have an xml extension).
To elaborate on rob's answer.
Make sure you open the debug view. Steps to open it: Window -> Show View -> Other -> (Search debug) -> Open
Then do what he references:
Run your application
Go to your Debug perspective
There should be an entry in there (in the Debug View) for the app you've just executed
Right-click the node which references java.exe or javaw.exe and select Properties In the dialog that pops up you'll see the Command Line which includes all jars, parameters, etc
Scan your workspace .metadata directory for files called *.launch. I forget which plugin directory exactly holds these records, but it might even be the most basic org.eclipse.plugins.core one.

Pydev; How Do I Config *all* .py To NOT Run In Ant?

Beginner config question here, guys.
So I am in eclipse, in pydev. Some of my src will run in the python compiler just fine, but others try and run in ant. When I click the 'Run' dropdown in the ones that work, and select 'Run As' I get two options. 'Python Run' and 'Python Unit-test'. When I try and run the ones that try and use Ant, I goto the same menu and it only displays '(none applicable)'
How do I fix this?
I was having the same problem. If you were,like me, trying to run code that you had written in IDLE and saved somewhere. You have to create blank project and import that code into the "src" folder of your project. then you should be able to run the code as python in eclipse.
For example. I had a bit of code I was trying out in IDLE saved in a folder in "My Docs". I moved it to my project "src" folder in "Mydocs/eclipse/projects/" and was able to run it in eclipse. Your paths will depend on where you opted to save your eclipse projects.
You should then be able to select your "Python: run option.
This was the link that helped me with this.
http://www.vogella.com/articles/Python/article.html#installation_python
Read the whole thing and it should help.

How can I get MoreUnit to debug tests rather than run them?

I've just started using MoreUnit and it seems quite handy. One thing that I am missing however is how to run tests using the debugger right away rather than just plain Run (using ^R).
It's not in the context menu and I have tried a few keyboard shortcut variations to no avail...
Usually in Eclipse, you can just click on the debug button after running the tests normally to debug them (the last run will have created a launch configuration that you can also access from the debug menus).
Other than that, you should find a "Run as MoreUnit test..." in both the "Run" and "Debug" menus (if not, file a feature request).
Lastly, you should be able to open the "Launch Configuration" wizard by selecting "Debug..." and there should be a folder for MoreUnit in the tree on the left. Above the tree is a "+" option to create entries in a folder.

Make Eclipse "run configuration" show up in context menu of specified file type

I have a simple Eclipse run configuration launching a Perl script to process an XML file. Nothing special, works alright.
However, picking the run configuration is a bit awkward. My entry doesn't show up in the first level of the context menu. It doesn't show up either under "Run As". I have to pick "Run As > Run Configurations ..." to then select my run configuration "import XML".
The way I'd like this to work is to select one or more XML files and then pick "import XML" (the name of my run configuration) from the context menu. Heck, the best thing would even to be able to double-click the XML file to launch it such as in Windows Explorer. Actually, it would be best if Eclipse were able to determine the applicability of my run configuration "import XML" based on the filename and folder location. Like, make the rc available for all files in Database/XML ending in .xml and not starting with Hooks.
Is there a way to get somewhere near that point? If some Java programming is involved that's not a problem.
The thing you're after is called launch shortcut, check out Eclipse help.
If you want to get something into the first level of context menu, use org.eclipse.ui.menus extension point. Double-click is associated with opening a file in editor. While it is possible to define your launch configuration as an editor, it's certainly not a good practice.
My entry doesn't show up in the first level of the context menu. It doesn't show up either under "Run As". I have to pick "Run As > Run Configurations ..." to then select my run configuration "import XML".
I don't think any run configurations are supposed to show up in the context menu under Run As, although it seems like it should probably contain recently used configurations, to mirror the toolbar run/debug/etc. buttons. Speaking of which, does your launch configuration show up under the run button? It should. That might be the easiest way to go about this.
The way I'd like this to work is to select one or more XML files and then pick "import XML" (the name of my run configuration) from the context menu. Actually, it would be best if Eclipse were able to determine the applicability of my run configuration "import XML" based on the filename and folder location. Like, make the rc available for all files in Database/XML ending in .xml and not starting with Hooks.
Eclipse can't do anything like this out of the box. It's entirely possible to write your own plug-in to do this, though I imagine the effort required would be enough to make it not worth it for what sounds like a one-off program. If I were you I'd probably just keep a console window open and run it from there, or make a really really simple gui to do this.
Some googling has shown that what I'm looking for, i.e. a context menu plug-in, has already been done; it is aptly named the ContextMenuPlugin for Eclipse.

Eclipse: bind some key for all unit tests

I practice TDD and run my tests very often. Eclipse has a nice command to run the last-launched configuration. But when I invoke the command in some unit test class, Eclipse runs only the tests for current unit test class. I want run all my unit tests instead.
Yes, I can use the mouse to invoke the command that runs all JUnit tests, but, to repeat: I run tests very often.
You need to change eclipse's run mode. By default, it will try to run whatever is selected or being edited. You want to it always run the "last thing executed".
Go to Window->Preferences->Run/Debug->Launching
Choose "Always Launch the Previous Application"
Then you can define a TestSuite with all of your test cases and run it, or run all test cases for the project. Once run, you can just keep re-running with F11 or control-F11.
Hope this helps!
-- Scott
Maybe Infinitest is what you need.
You can create a JUnit launch configuration for all of your tests by right clicking the tests folder and choosing "Run As > JUnit Test".
Then see https://stackoverflow.com/a/8176077/255961 which describes how to use the Practically Macro plugin to assign shortcuts to launch configurations.
PS, If for some reason you have tests in more than one folder you can then edit the JUnit launch configuration to work at the project level as well:
To run all unit tests in a project, package or source root, select the item in the package explorer and hit Shift+Alt+X then T (or right click->Run As-> JUnit test).
To get the focus on the package explorer, hit Ctrl+F7 to bring up the "Next View" menu, hit it repeatedly to cycle through the list or hit up and down arrow then enter to select the view.
Once you've run it once, F11 can be set to run the last launched if you tweak the debug preferences (the default is to run for the current selection).
There is also Junit Max. It is not free but very cheap. It will run all your tests every time you save a file and indicate if the tests were successful in the right bottom corner of eclipse.
If a tests fails the line where it fails is marked as an error so you can keep working with the source files and don't have to wait for your tests and have your workflow interrupted.