Run PHPUnit tests of Symfony 2 application under Netbeans 7.1
Asked Answered
D

3

12

I've spent some time to figure out how to configure Netbeans 7.1 to work with Symfony 2 and PHPUnit, but I didn't succeed. When I try to run any test under console, there is no problem. But when running using shift+F6, it returns

"PHP Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found"

Does anybody know how to succeed with such kind of configuration?

Direct answered 8/1, 2012 at 22:23 Comment(1)
Make sure you have pointed NetBeans to your phpunit.xml and bootstrap.php files. The latter must set up the include path and autoloader (if necessary). It might help if you can post your bootstrap.php file too.Inefficient
C
20

I had the same issue with Netbeans 7.2 This is what I had to do:

  1. Right click on the symfony2 project -> Properties -> PHPUnit
  2. Here check on the "Use Bootstrap" and Browse to the \app\bootstrap.php.cache
  3. Also check on the "Use XML configuration" and Browse to \app\phpunit.xml.dist.

After saving, the ALT+F6 should work

Cassirer answered 22/8, 2012 at 23:33 Comment(5)
I also had to point it to a "directory with tests". I just gave it src/. Unfortunately, this makes all my custom source show up under "Test files", but I'm not sure how this can be helped. I also like using a custom suite to run only certain tests. See forum.symfony-project.org/viewtopic.php?f=23&t=33543Graphitize
I did what you wrote and NetBeans 7.2.1 asks me to define Test Source directory. It's confusing, since tests are inside different bundles all around src directory. Anyone had the same problem?Barm
Here is a solution for not defined Test dir: forum.symfony-project.org/viewtopic.php?t=33543 Basically, you have to create a custom test suite.Monogyny
@tkoomzaaskz It may sound like a lot of work but you can add multiple test directories e.g. src\Acme\AppBundle\Tests, src\Acme\App2Bundle\Tests, src\Acme2\FooBundle\Tests etc. - that will only put these files into the NetBeans Test Files folder.Butyraldehyde
On Netbeans 8.1 i had to use the \app\autoload.php instead of the \app\bootstrap.php.cache as bootstrap fileTame
C
1

Instead of putting src/ folder as a test folder, the better idea is to create symbolic link by executing:

mklink /D tests src

inside project folder in Windows. This way we have src folder in "Source files" and phpunit testing works great.

I can't answer to Kristóf Dombi answer so I have to put this answer here.

Circumlunar answered 28/6, 2013 at 9:1 Comment(0)
S
0

I'm using Symfonyv7 with Netbeans IDE21.

Right click on the symfony project -> Properties
Project Properties

  • Window will open
  1. In Categories(On the left) -> Testing
    • Test Directories: Add your /tests folder.
  2. In Categories(On the left) -> PHPUnit
    • Select(check) Use Bootstrap.
      • Browse and select /tests/bootstrap.php
    • Select(check) Use XML Configuration.
      • Browse and select /phpunit.xml.dist
    • Select(check) Use Custom PHPUnit Script.
      • Browse and select /bin/phpunit

Optionally, you cal select(check)

  • Use Bootstrap for Creating New Unit Tests
  • Test Project Using Just 'phpunit' Command
  • Run All *Test.php Files in Project Using PHPUnit

Reference

enter image description here

Separate answered 26/4 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.