NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
PHPEd and PHPUnit - Project Contains No Tests


Joined: 30 Jan 2008
Posts: 7
Location: UK
Reply with quote
I don't need help, I'm just posting here in case anyone else experiences the same issue and hopefully save them some time. I installed phpUnit, set up a test, and opened the test suite, but it said 'project contains no tests'. Even though I could see my test file under the 'Test Files' folder in the project directory structure in phpEd, the test suite could not find it. When I scanned the project it said 'no new tests discovered'.

I finally worked out that the reason for this was that the file name did not exactly match the name of the class. After renaming the file so that it exactly matched the name of the class contained within, test suite was then able to detect it (this is not a requirement of phpUnit - I could run the test from the command line ok, but it apparently is a requirement of phpEd's test suite).
View user's profileFind all posts by netshineSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7857
Reply with quote
Quote:
this is not a requirement of phpUnit


I'm not sure what you mean. PhpED follows logic of phpUnit and finds tests in all files that have certain pattern, then filters classes that also have certain pattern. Class names don't have to match filenames.
Say, if you have file abc.php and it contains class cba, it won't be found neither by phpUnit nor by PhpED, right?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
PHPED and PHPUNIT INTEGRATION HOW IT WORKS?


Joined: 09 Sep 2016
Posts: 4
Reply with quote
Hi,

I am new in PHPUnit. I would like to use it from PHPED 17. It seems something wrong. I don't know if I need PEAR. WHat I read is no longer needed. I have the right path for PHUNIT in settings and my projects. I have configured a folder for test. I create a simple example in test folder but the testunit suit inform there is no test available. SO, it seems somthiong wrong. I will try to use phpunit from command line but it would be more confortable for the IDE. Could you help me?
View user's profileFind all posts by roger73Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7857
Reply with quote
You don't need PEAR, it's not used anymore. What you need is php sufficiently new (see phpUnit requireements for the phpUnit version you configured)
I'd recommend you to try sample from https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html
Save the following code into testStack.php file in the folder you created:
Code:
<?php
use PHPUnit\Framework\TestCase;

class StackTest extends TestCase
{
    public function testPushAndPop()
    {
        $stack = [];
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}
?>

Then open Tools->Show Test Suite (F6) and click Run All button.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 09 Sep 2016
Posts: 4
Reply with quote
Thanks dimitri.
Now it works. The main problem - my fault - is I must start each test method with test. I didn't do that. So,

public function mytest()
{
}

doesn't work. It works

public function testmytest()
{}

My second goal is use bootrap due I using autoload class based on namespace. I am a bit stacked hahah
View user's profileFind all posts by roger73Send private message
PHPEd and PHPUnit - Project Contains No Tests
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic