Check this

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Check this

Post by kpraman »

JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php 
set_include_path("library/"); 

require_once 'members.php'; 
require_once 'PHPUnit/Framework/TestCase.php'; 
require_once 'PHPUnit.php'; 

class MembersTest extends PHPUnit_TestCase { 



function test_insert() 
{ 
$new=new Members; 
$dbActual=$new->AddOrUpdateMember('a','b','c','d','e','f','g','h','i','j','k','','table1'); 
$dbExpected=1; 
$this->assertTrue($dbExpected=="$dbActual", "INSERT FAILED"); 
} 

} 

$suite = new PHPUnit_TestSuite('MembersTest'); 
$result = PHPUnit::run($suite); 
print $result->toHTML(); 
?>

is there anything wrong in the code? I also want to know, if i change the function name test_insert(), it does not work. If i want to write a new function, what should i do?


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

All test case methods must start with the word "test..." so if you remove the initial 4 letters it won't run. You can add your own functions but you'll have to call them manually. If you're testing something make a new method like "testSomethingElse()". I'm sure this will be covered in the PHPUnit documentation/cookbook :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

kpraman, please try to make a slightly more descriptive subject line next time, and also please start using the highlighting tags. If you don't know what they are or how they work, follow the links that have been added to your post above by JayBird.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

Thanks for ur replies.

I have writte the code for delete, update etc. When i run, i get results,

TestCase MembersTest->testing_insert() passed
TestCase MembersTest->testing_insertNotable() passed
TestCase MembersTest->testing_insertWithoutid() passed
TestCase MembersTest->testing_update() passed
TestCase MembersTest->testing_updateNoid() passed
TestCase MembersTest->testing_updateData() passed
TestCase MembersTest->testing_insertData() passed
TestCase MembersTest->test_DeleteNoid() passed
TestCase MembersTest->test_Delete() passed
TestCase MembersTest->test_EnableMemberTest() passed
TestCase MembersTest->test_EnableMemberNottrueTest() passed

What should i do next?
Post Reply