Yii Framework Forum: NetBeans IDE and Test Driven Development - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

NetBeans IDE and Test Driven Development Rate Topic: -----

#1 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 16 September 2010 - 03:26 PM

While going through the Yii book I started my first practical experience with test driven development.
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?
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#2 User is offline   ekerazha 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 526
  • Joined: 10-October 08
  • Location:European Union

Posted 17 September 2010 - 03:30 AM

Small question... when you run all the tests, do you also get "SKIPPED" as first result (and output is Fatal error: Class 'WebTestCase' not found in ...)?

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).
Yii user #37
0

#3 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 17 September 2010 - 05:29 AM

View Postekerazha, on 17 September 2010 - 03:30 AM, said:

Small question... when you run all the tests, do you also get "SKIPPED" as first result (and output is Fatal error: Class 'WebTestCase' not found in ...)?


I noticed these errors with PHPUnit < 3.4.x.



0

#4 User is offline   ekerazha 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 526
  • Joined: 10-October 08
  • Location:European Union

Posted 17 September 2010 - 07:31 AM

View PostMike, on 17 September 2010 - 05:29 AM, said:

I noticed these errors with PHPUnit < 3.4.x.

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).
Yii user #37
0

#5 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 19 September 2010 - 04:54 AM

Quote

... but I cannot run just a single test.

Just right click your test file and select Run(Or select your test file and press shift+F6).
1

#6 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 21 September 2010 - 02:23 AM

Run was the function I was looking for for single files :)

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..
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#7 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 21 September 2010 - 04:30 AM

Right click your projrct. Select Properties. Select PHP Include Path. Click Add Folder to add your yii framework folder.
1

#8 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 21 September 2010 - 08:07 AM

Here's an extra tip:

- 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.
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#9 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 21 September 2010 - 08:42 AM

I've created a Cookbook page with NetBeans info: http://www.yiiframew...oc/cookbook/83/
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
1

#10 User is offline   Ben 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 270
  • Joined: 15-March 09

Posted 26 September 2010 - 05:45 PM

Can anyone help me to get this working, please?

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...
Don't like ads in my sig...
0

#11 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 28 September 2010 - 03:25 AM

View PostBen, on 26 September 2010 - 05:45 PM, said:

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.


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.
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#12 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 28 September 2010 - 09:07 AM

I have installed netbeans v6.8,

Is there any reason for not upgrading to 6.9.1?
0

#13 User is offline   Ben 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 270
  • Joined: 15-March 09

Posted 30 September 2010 - 03:55 PM

View Postmarcovtwout, on 28 September 2010 - 03:25 AM, said:

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.


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. :unsure:


View Postabajja, 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.
Don't like ads in my sig...
0

#14 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 01 October 2010 - 02:50 AM

Quote

But no luck with the functional tests till now.

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.
0

#15 User is offline   Ben 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 270
  • Joined: 15-March 09

Posted 01 October 2010 - 01:24 PM

:lol: It's working now!

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

There was 1 error:

1) SiteTest::testLoginLogout
PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
ERROR: Element link=Logout not found.

Don't like ads in my sig...
0

#16 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 02 October 2010 - 06:01 AM

Quote

ERROR: Element link=Logout not found.

see:


http://code.google.c...Summary&id=1609
0

#17 User is offline   Prasetyo Aji 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-February 09

Posted 14 March 2011 - 06:03 AM

install PHPUnit on Xampp,but not working... help me
i try this .... My link
0

#18 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 14 March 2011 - 08:01 AM

View PostPrasetyo Aji, on 14 March 2011 - 06:03 AM, said:

install PHPUnit on Xampp,but not working... help me
i try this .... My link


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.
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#19 User is offline   rushino 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 24-May 11

Posted 25 May 2011 - 08:30 PM

I figured out how to install NetBeans 7.0 with WAMP and PHPUnit. I will be posting a link soon. Was a pain but everything work as it is supposed now!
0

#20 User is offline   zipzap 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 314
  • Joined: 13-January 12

Posted 19 January 2012 - 05:12 PM

Quote

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?


how do you do that?

im getting Fatal error: Class 'CTestCase' not found in netbeans
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users