Contents
- ./tests/CDTest.java
- ./tests/DVDTest.java
- ./tests/MediaItemTest.java
- ./tests/TestAll.java
./tests/CDTest.java 1/4
[top][prev][next]
/**
*
*/
package media.tests;
import static org.junit.Assert.*;
import java.util.GregorianCalendar;
import media.CD;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* JUnit test class for CD class. This test class likely won't work for you because it's for my CD class.
*
* @author Sara Sprenkle
*
*/
public class CDTest {
private CD myCD;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
myCD = new CD("title", 100, new GregorianCalendar(1997, 1, 1),
"artist", 14);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link media.CD#getArtist()}.
*/
@Test
public void testGetArtist() {
assertEquals("artist", myCD.getArtist());
}
/**
* Test method for {@link media.CD#getNumTracks()}.
*/
@Test
public void testGetNumTracks() {
fail("Not yet implemented");
}
}
./tests/DVDTest.java 2/4
[top][prev][next]
package media.tests;
import static org.junit.Assert.*;
import java.util.GregorianCalendar;
import media.DVD;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* JUnit test class that tests the DVD Class -- likely won't work for your class.
*
* @author Sara Sprenkle
*
*/
public class DVDTest {
private DVD mydvd;
@Before
public void setUp() throws Exception {
mydvd = new DVD("That Thing You Do!", 6480, new GregorianCalendar(1996,
9, 4), "PG", 3600);
}
@After
public void tearDown() throws Exception {
}
@Test
public void testGetLength() {
assertEquals(10080, mydvd.getLength());
}
@Test
public void testToString() {
assertEquals(
"*** DVD\nCurrently in the library?: Yes\nTitle: That Thing You Do!\nLength: 2:48:00\nCopyright Year: 1996\nRating: PG",
mydvd.toString());
}
@Test
public void testGetBonusLength() {
assertEquals(3600, mydvd.getBonusLength());
}
@Test
public void testGetRating() {
assertEquals("PG", mydvd.getRating());
}
}
./tests/MediaItemTest.java 3/4
[top][prev][next]
/**
*
*/
package media.tests;
import static org.junit.Assert.*;
import java.util.GregorianCalendar;
import media.DVD;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* JUnit test class for the MediaItem class.
* Tests the MediaItem class's methods, using a DVD object.
* Likely won't work with your MediaItem class.
*
* @author Sara Sprenkle
*
*/
public class MediaItemTest {
private DVD mydvd;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
mydvd = new DVD("That Thing You Do!", 6480, new GregorianCalendar(1996,
9, 4), "PG", 3600);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link media.MediaItem#getCopyrightDate()}.
*/
@Test
public void testGetCopyrightDate() {
assertEquals(new GregorianCalendar(1996, 9, 4).getTime(),
mydvd.getCopyrightDate());
}
/**
* Test method for {@link media.MediaItem#getCopyrightYear()}.
*/
@Test
public void testGetCopyrightYear() {
assertEquals(1996, mydvd.getCopyrightYear());
}
/**
* Test method for {@link media.MediaItem#getFormattedPlayTime()}.
*/
@Test
public void testGetFormattedPlayTime() {
assertEquals("2:48:00", mydvd.getFormattedPlayTime());
}
}
./tests/TestAll.java 4/4
[top][prev][next]
package media.tests;
import org.junit.runner.JUnitCore;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* The class <code>TestAll</code> builds a suite that can be used to run all
* of the tests within its package as well as within any subpackages of its
* package.
*
* @generatedBy CodePro at 10/29/12 2:12 PM
* @author sprenkle
* @version $Revision: 1.0 $
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
CDTest.class,
})
public class TestAll {
/**
* Launch the test.
*
* @param args the command line arguments
*
* @generatedBy CodePro at 10/29/12 2:12 PM
*/
public static void main(String[] args) {
JUnitCore.runClasses(new Class[] { TestAll.class });
}
}
Generated by GNU Enscript 1.6.6.