OrganismTester - import junit.framework.TestCase; /* * A...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import junit.framework.TestCase; /** * A JUnit test case class. * Every method starting iwht the word "test" will be called when running * the test with JUnit. */ public class OrganismTester extends TestCase { public void testOrganism(int lev) { Organism x= new Organism(0); assertEquals(0, x.getLevel()); assertEquals(0, x.getMercury()); assertEquals(null, x.getNickname()); assertEquals(true, x.isAlive()); assertEquals(0, x.getNumVictims()); } public void testGetters() { Organism a=new Organism(0, 0, null); assertEquals(0, a.getLevel()); assertEquals(0, a.getMercury()); assertEquals(null, a.getNickname()); assertEquals(true, a.isAlive()); assertEquals(null, a.wasEatenBy()); assertEquals(0, a.getNumVictims()); Organism b= new Organism(0, 0, "fish"); assertEquals(0, b.getLevel()); assertEquals(0, b.getMercury()); assertEquals("fish", b.getNickname()); Organism c= new Organism(0, 5, null); assertEquals(0, c.getLevel()); assertEquals(5, c.getMercury()); assertEquals(null, c.getNickname()); Organism d= new Organism(0, 10, "fish");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

OrganismTester - import junit.framework.TestCase; /* * A...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online