I noticed on Can't get Zend Studio and PHPunit to work together that a comment says
If you want ZS to run the PHPunit bootstrap, you have to specifically
select the file PHPunit.xml and tell it to run as PHPunit test. If you
just select an individual test and run as PHPunit test, the bootstrap
will not be run
That trick actually helped me to be able to run unit tests at all. However as my unit tests grow, it's becoming more and more painful to have to run the entire test suite when I just need to run my most recently written test.
So I need help adding the necessary code to the unit test (presumably in setUp) so that both the tests/bootstrap.php and the regular bootstrap for the whole application run. Hopefully this would let me do right click -> run as -> PHPUnit Test on an individual test file.
I'm new to Zend / Zend Studio so please keep answers on a basic level. The current setUp() function for one of my tests is the following, which I believe runs the whole app's boostrap:
public function setUp() {
$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
parent::setUp();
}
How does this need to change to enable running just this test file in isolation? (which I think involves calling both the tests/bootstrap.php and the application bootstrap as above)
You have to setup phpunit with zend studio / eclipse first, then you can run each unit test file individually in your IDE console.
Here's a tut that might help
Related
I'm creating my first VS Code extension, but now I stuck while testing my extension automatically.
If I run my automated tests out of VS Code everything works fine, but I want to run the tests also in a continuous integration pipeline which is why the tests should also run if I call them with npm run test.
With npm run test most of my tests run successful, but as far as a test-method depends on the "vscode.executeDefinitionProvider"-output the tests fail, because it does not find any definitions.
await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', document.uri, positionToSearchForSymbols)
.then(definitions => {
if(definitions.length > 0){
//this one is called if I run the tests out of Visual Studio Code
} else{
//this one is called if I run the tests via npm rum test
}
});
Do you have any idea what I'm doing wrong? Why does npm run test behave different than running the tests out of VS Code?
Thanks in advance for your help.
David
Well, I got informed that VS Code sends a message to the language provider (in my case the al language extension) and that the issue has to be on the site of the language provider. Because the issue is not related to VS Code, I will close this question.
You need to setup your test environment to use specific extensions: How do I run integration tests for a vscode extension that depends on other extensions
You need to make sure that the extensions (in your case: DefinitionProvider) are activated before your tests start:
VSCode extension testing: Use `vscode.executeDefinitionProvider` in test
You might run into a situation where nothing of the above works for you. In that case this might help:
https://stackoverflow.com/a/69400358/6702598
I am using Netbeans 8.1 with CUnit testing. I can run and test my project just fine, and it spits out the correct results. However, when I try to test it again it does not give me results. Instead it only says:
CUnit - A unit testing framework for C - Version 2.1-3
http://cunit.sourceforge.net/
This persists even if I change the actual code of the project. It will only give me the results when I restart the program. I would like to know how to get the updated test results without having to restart the program.
I found a workaround: add a dummy C Simple Test test that always passes.
Turned out if I have C Unit and C Simple Test tests in the same project and when I run Test Project from the menu both works properly.
Hi i created a unit test case using NUnit.When i run the test NUnit it works fine.But i need to run it by using Visual studio.So i referred the NUnit website and followed the below steps
1)Right clicked the test project and clicked properties |Chose Debug option
2)checked the external program option and choosed the nUnit exe file.
3)And i run the test
Error i got:
Cannot start because the test project does not contain any test method.But i included 4 test methods which works in NUnit GUI.
Thanks in advance
Check out TestDriven.NET, a free Visual Studio add-in that allows you to run your unit tests with NUnit directly from the IDE.
Also ReSharper beautifully supports testing with NUnit!
http://www.jetbrains.com/resharper/features/unit_testing.html
On the Debug options tab, make sure to also set a command line argument with the name of your test assembly.
I need to create the NUnit Test case automatically from my .Net Solution file.
Morover this needs to be done , from command line.
I heard Pex create test cases automatically.
Let know
The following steps should get you there:
Add a reference to Pex.NUnit.dll in your test project
In your test project's AssemblyInfo.cs, add the attribute - [assembly: Pex.NUnit.PexNUnitPackage]
Build your solution (either from Visual Studio or using msbuild from the command line)
run Pex from the command line: pex.exe bin\Debug\TestProjectName.dll
The tests are placed under reports\TestProjecName.#####.#####\tests.
You can read more about this in Exercise 5 of Parameterized Unit Testing with Microsoft Pex
Ryan Gross' answer
points to the right direction.
However Pex.exe generates Unit Tests from Parameterized Unit
Tests, not from
application classes itself.
To generate Parameterized Unit Tests you need to run pexwizard.exe
pexwizard.exe <your assembly name> options
Possible options are described in
http://testoriented.googlecode.com/svn-history/r89/suitability/trunk/Tools/Pex-0.22.50128.1/pexwizard.txt
I am building an app using ActionScript3 with Flash Builder 4 as my IDE.
The IDE supports a unit testing framework called "FlexUnit".
I can build and run tests within the IDE, no problem.
After much pain and suffering I figured out how to build the unit tests as a swf from the command line. I can point a browser or flash player at the swf and the tests run.
But for an automated build system this is no good: I would like to build the tests, run them, and collect/analyze the results to tell which tests, if any, are failing.
I can imaging some hackery: hack FlexUnit base libraries to dump output to stderr instead of just to the IDE console. Hack some script together that points a browser at the swf, counts to 60, kills the browser and checks stderr.
But that's hideous.
I have to believe there's some way to build and run from the command line that works nicely with automated build systems.
Further complication: I am a relative noob with ActionScript (~1 month). My background is C++, makefiles, etc. All the stuff I had to do to get the tests even to build outside the ide (a build.xml file, ant) was complete greek to me, just cut n pasting from examples I could find.
As far as I'm aware your only options for running the swf are in the browser or in the standalone player. Running in the player should not be a problem for your continuous integration environment as long as you can get at the test results and exit the application.
To print test results to stdout you need to add a Text listener to your testunit core instance.
core.addListener( TextListener.getDefaultTextListener( LogEventLevel.DEBUG ) );
To exit the application after the tests have run...
System.exit(0);
For example, your top level mxml file might look like this...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="runMe()"
xmlns:adobe="http://www.adobe.com/2009/flexUnitUIRunner"
>
<mx:Script>
<![CDATA[
import org.flexunit.runner.FlexUnitCore;
//import org.flexunit.listeners.UIListener;
//import org.flexunit.listeners.CIListener;
import org.flexunit.internals.TextListener;
import mx.logging.LogEventLevel;
import flash.system.System
import unit_tests.TestAuthentication.TestAuthentication
private var core:FlexUnitCore;
public function runMe():void {
core = new FlexUnitCore();
//core.addListener(new UIListener(uiListener));
//core.addListener(new CIListener());
core.addListener( TextListener.getDefaultTextListener( LogEventLevel.DEBUG ) );
core.run( TestAuthentication );
System.exit(0);
}
]]>
</mx:Script>
</mx:Application>
Then all you need to do is parse the output.
It's not as elegant as we might like but it should work.
This post have a solution : http://devnet.jetbrains.com/message/5507979#5507979 . Works for me like a champ.