java - JUnit Test - Class invokes methods in other class -


i have class player has method

 feedpet(pet p1, food f1){  p1.eat(f1)   } 

so feedpet invokes pets eat method, eat method adjusts pets hunger level.

to test need create player , food object in junit test case.

i test working simple

 assertequals(p1.gethunger,3); 

p1 pet object have created in player test case.

my question , doing appropriate? , testing player class correctly?

really testing if eat method pet works need check feedpet method works player well.

any thoughts or advice appreciated.

what should ideally create 2 test files -one pet class tests eat method , player class tests feedpet method.

when write

assertequals(p1.gethunger,3); 

i hope hunger instance variable set under eat method of pet class, per expectation 3. if that's case on right path


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -