NetBeans IDE and Test Driven Development
#1
Posted 16 September 2010 - 03:26 PM
I am using NetBeans IDE for my php development sinds recently, but discovered it has some build in capabilities for PHP Unit, and a plugin for Selenium RC.
I got it working so that it runs the functional tests and unit tests all at once, but I cannot run just a single test.
Anyone out here wanting to do the same thing?
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
#2
Posted 17 September 2010 - 03:30 AM
Also, small suggestion (not related to your question) the Selenium PHP plugin for NetBeans is bundled with Selenium 1.0.1 and I had issues when testing with Firefox, so I downloaded the last Selenium version and replaced the selenium-server file inside the plugin folder (you have to use the same filename of the original file).
#4
Posted 17 September 2010 - 07:31 AM
Mike, on 17 September 2010 - 05:29 AM, said:
I've read some messages about this, but I'm using 3.4.15 and I still notice that error (I already tried to re-install PHPUnit several times).
#5
Posted 19 September 2010 - 04:54 AM
Quote
Just right click your test file and select Run(Or select your test file and press shift+F6).
#6
Posted 21 September 2010 - 02:23 AM
Has anyone set up his project to also include Yii framework code/documentation, instead of just the generated application? I would like to have it while autocompleting functions and such..
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
#7
Posted 21 September 2010 - 04:30 AM
#8
Posted 21 September 2010 - 08:07 AM
- Goto: Tools/Options/Miscellaneous/Files
- Add to the front of "Files Ignored by the IDE" the file "^(yiilite.php|CVS|SCCS|...."
- Restart NetBeans
This way you don't get double and undocumented code from yiilite.php in your autocomplete tooltips.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
#9
Posted 21 September 2010 - 08:42 AM
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
#10
Posted 26 September 2010 - 05:45 PM
I have installed netbeans v6.8, phpunit v3.5 and netbeans' plugin "Selenium Module for PHP" v1.0. I started with an empty webapp created by yiic, then created a new netbeans project with existing source.
Setting up the test directory was the first trouble: for some reason, I can't do that in the project properties (text field takes no input). So I tried to generate a test case for the LoginForm model. This drives netbeans to ask for a test folder, which I set to protected/tests. The generation of the unit test fails, because PHPUnit doesn't find the class CFormModel. But the project explorer now shows a folder "Test Files" below "Source Files". Guess that is okay...
Now I thought it was time to check if unit testing works, so I put a dummy test for LoginForm into tests/unit:
class LoginFormTest extends CTestCase
{
public function testRules()
{
$loginForm = new LoginForm();
// just wanna know if PHPUnit works
$this->assertTrue( count($loginForm->rules()) === 3 );
}
}
When I tried to run that test, PHPUnit again complained that it didn't know CTestCase, so I configured it to use tests/bootstrap.php as bootstrap file. Now the single test passes, but I can't figure out how I would run all my unit tests?
Pressing <Alt> + <F6> took a while, and resulted in some errors. Something about IE could not been started (sure, I'm on Ubuntu right now) and that a connection to selenium rc could not be established. Until this point, I only wanted to do some unit testing, so I don't know why netbeans tried to start functional tests. Maybe because of the "functional" folder within the "Test Files"? I can only guess, that netbeans tries to start every file within this folder if you just say "test"...
Okay, moving on. Trying to get functional tests working...
I reviewed WebTestCase.php (changing the TEST_BASE_URL), bootstrap.php (seems okay) and phpunit.xml (removing the browser entry for IE). I also configured PHPUnit to use the phpunit.xml file as XML configuration and disabled the bootstrap checkbox, since the xml seems to configure it already.
Single unit test still works, <Alt> + <F6> still fails. Some Details: LoginFormTest passes, SiteTest is skipped (no valid test cases found), SiteTest (Firefox) fails (could not connect to selenium rc server). So SiteTest seems to be executed twice, first as unit test, second as functional test. Not what I intended to do...
Trying to run only functional tests, I came across the problem, that the menu entry wasn't enabled. I told netbeans to create a new "Selenium Test Case for PHP", which again brought up a dialog that allowed me to specify a test folder. A chose protected/tests again, then canceled the dialog. Now I was able to select "Run selenium tests" from the project folder. The output was exactly the same as when I pressed <Alt> + <F6>. Still no connection to selenium rc server, plus unit tests I didn't intend to run.
Last try: select different folders for unit testing and functional testing. Since die IDE doesn't provide a possibility to configure these settings once they are set, I edited nbproject/project.properties. I set test.src.dir to protected/tests/unit and selenium.src.dir to protected/tests/functional. This gave me a new folder in the project explorer: Besides "Source Files" and "Test Files", there were now a folder called "Selenium Test Files".
Result: Single Test still worked. <Alt> + <F6> still tries to do everything (isn't it possible to only do unit tests?!), "Run Selenium Tests" also tries to do everything. Pretty annoying.
I also tried to configure the selenium plugin to use chrome instead of firefox, but without luck, same result (can't connect to selenium rc server). I'm pretty sure it is running, since I can't start it manually from the console (downloaded it before I realized the plugin comes with its own copy). If I exit netbeans, I can start it manually.
Is there anyting I've missed? Something I haven't yet though of? More configuration files that need to be ajusted? I'm really running out of ideas here...
#11
Posted 28 September 2010 - 03:25 AM
Ben, on 26 September 2010 - 05:45 PM, said:
Setting up the test directory was the first trouble: for some reason, I can't do that in the project properties (text field takes no input). So I tried to generate a test case for the LoginForm model. This drives netbeans to ask for a test folder, which I set to protected/tests.
You cannot enter anything in the text field directly, but you can use the browse button to the right. Anyways, you set up the test path correctly.
Shift-F6 is the correct hotkey for testing single files. Alt-F6 will run all tests
Try updating the version of Selenium RC. A previous post in this topic suggests 1.0 has problems with Firefox.
I have never tried generating test cases from NetBeans, only created my own class files for unit testing.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
#12
Posted 28 September 2010 - 09:07 AM
I have installed netbeans v6.8,
Is there any reason for not upgrading to 6.9.1?
#13
Posted 30 September 2010 - 03:55 PM
marcovtwout, on 28 September 2010 - 03:25 AM, said:
Shift-F6 is the correct hotkey for testing single files. Alt-F6 will run all tests
Try updating the version of Selenium RC. A previous post in this topic suggests 1.0 has problems with Firefox.
I have never tried generating test cases from NetBeans, only created my own class files for unit testing.
There's no browse button in v6.8, seems they simply forgot it. ^^
Luckily that's not much of a problem.
I've read the post about the problems with firefox, that's why I also tried with chromium. Of course it's possible that both browsers have the same problem, so at least I'm willing to upgrade the selenium server. The problem is, that I've no idea where those netbeans plugins get installed. And ekerazha mentioned, that one has to use the filename of the original file, which sounds to me as if it was something different that 'selenium-server.jar', so I have no clue what to search for.
abajja, on 28 September 2010 - 09:07 AM, said:
I have installed netbeans v6.8,
Is there any reason for not upgrading to 6.9.1?
No specific reason, I simply installed it using synaptic. Now I updated to 6.9.1, and at least, there is the button that let's me select the folder for unit tests in the settings dialog. But no luck with the functional tests till now.
Thanks for your replies! If anyone has more suggestions, please let me know.
#14
Posted 01 October 2010 - 02:50 AM
Quote
You might want to do some changes:
0.- Rename your selenium-server.jar to selenium-server-1.0.1.jar and place it in your userdir by default it is in my widowsxp pc under C:\Documents and Settings\Bajja.ISSP_00\.netbeans\6.9\modules\ext\selenium
1.- Right click your project. Select PHPunit. Activate Use Bootstarp (and browse to you bootstarp file) and Use Bootstarp for creating New unit Tests.
2.- In WebTestCase.php change setUp:
protected function setUp()
{
parent::setUp();
[b]$this->setBrowser('*chrome');[/b]
$this->setBrowserUrl(TEST_BASE_URL);
}3.- In WebTestCase.php change
define('TEST_BASE_URL','http://localhost/[b]testdrive[/b]/index-test.php/'); //testdrive => must be your application.If this does not work, please report your errors.
#15
Posted 01 October 2010 - 01:24 PM
The problem was the outdated selenium-server (1.0.1). I found it in ~/.netbeans/6.9/modules/ext/selenium (don't know why my search didn't show it, maybe it doesn't search hidden folder by default? Have to check that...), replaced it with version 1.0.3 (named as 'selenium-server-1.0.1.jar'), restarted netbeans (just in case) and voilĂ !
Thanks a lot!
By the way, has anyone of you run the SiteTest generated by yiic? To me, it reports one error:
Quote
1) SiteTest::testLoginLogout
PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
ERROR: Element link=Logout not found.
#18
Posted 14 March 2011 - 08:01 AM
Prasetyo Aji, on 14 March 2011 - 06:03 AM, said:
You can start here: http://www.phpunit.d...stallation.html
And you have to be more clear about what steps you did and what results you get, 'not working' is not helping.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
#19
Posted 25 May 2011 - 08:30 PM
#20
Posted 19 January 2012 - 05:12 PM
Quote
how do you do that?
im getting Fatal error: Class 'CTestCase' not found in netbeans

Help














