NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Here's a script to run PHPUnit tests in NetBeans

 
Post new topic   Reply to topic    NetBeans Forums -> PHP Users
View previous topic :: View next topic  
Author Message
Sean DeNigris
Posted via mailing list.





PostPosted: Fri Feb 20, 2009 10:22 pm    Post subject: Here's a script to run PHPUnit tests in NetBeans Reply with quote

I hope some of you find this script useful...


This script automatically finds and runs test files (which end in "Test") in it's same directory. Set it as the index of a separate test project. In Netbeans configuration, set "Run As" to "Script" and arguments as "[whatever flags you want to send phpunit] AllTests [name of script file below]" e.g. "--verbose AllTests main.php" (no quotes) <?php // Add the directory of the classes under test to the include path $path = ini_get("include_path"); $projectPath = "/path/to/classes"; ini_set("include_path", $path . ":" . $projectPath); require_once 'PHPUnit/Framework.php'; class AllTests { public static function suite() { $suite = new PHPUnit_Framework_TestSuite('All Coffee Fund Unit Tests'); //$suite->addTestFile('MySqlSessionHandlerTest.php'); //$suite->addTestFile('PageProtectorTest.php'); // Automatically add all php files ending in "Test" to the suite // // Make an array of the file names in this script's directory $testProjectFiles = scandir(dirname(__FILE__)); // Seach the array for test files foreach ($testProjectFiles as $file) { //Get the end of the file name for comparison $lastEightOfFileName = substr($file, -Cool; // Add file to suite if it's a test file if ($lastEightOfFileName == "Test.php") { $suite->addTestFile($file); }; } return $suite; } } require_once '/path/to/phpunit'; ?>

Sean DeNigris
address-removed ([email]address-removed[/email])
Back to top
Tomas Mysik
Posted via mailing list.





PostPosted: Mon Feb 23, 2009 9:18 am    Post subject: Here's a script to run PHPUnit tests in NetBeans Reply with quote

Hi,
please note that from NetBeans 6.7 M2 it is possible to run PHPUnit tests
directly from the IDE. See our blog [1][2] for more information.

Tomas
[1] http://blogs.sun.com/netbeansphp/entry/phpunit_support_added
[2] http://blogs.sun.com/netbeansphp/entry/ui_for_phpunit_support


On pátek 20 února 2009 23:22:42 Sean DeNigris wrote:
Quote:
I hope some of you find this script useful...

This script automatically finds and runs test files (which end in
"Test") in it's same directory. Set it as the index of a separate
test project.

In Netbeans configuration, set "Run As" to "Script" and arguments as
"[whatever flags you want to send phpunit] AllTests [name of script
file below]"

e.g. "--verbose AllTests main.php" (no quotes)

<?php

// Add the directory of the classes under test to the include path
$path = ini_get("include_path");
$projectPath = "/path/to/classes";
ini_set("include_path", $path . ":" . $projectPath);

require_once 'PHPUnit/Framework.php';

class AllTests
{
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('All Coffee Fund
Unit Tests');
//$suite->addTestFile('MySqlSessionHandlerTest.php');
//$suite->addTestFile('PageProtectorTest.php');

// Automatically add all php files ending in "Test" to the suite
//

// Make an array of the file names in this script's directory
$testProjectFiles = scandir(dirname(__FILE__));

// Seach the array for test files
foreach ($testProjectFiles as $file) {

//Get the end of the file name for comparison
$lastEightOfFileName = substr($file, -Cool;

// Add file to suite if it's a test file
if ($lastEightOfFileName == "Test.php") {
$suite->addTestFile($file);
};
}


return $suite;
}
}

require_once '/path/to/phpunit';

?>

Sean DeNigris
address-removed

--
Tomas Mysik
address-removed
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> PHP Users All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo