Skip to content

Writing a unit test

cyian-1756 edited this page Jun 23, 2018 · 2 revisions

Step 1: Create the unit test file

Create the unit test file in src/test/java/com/rarchives/ripme/tst/ripper/rippers

File should follow the naming scheme RipperTest.java

Step 2: Extend the RippersTest class

public class YoursiteRipper extends RippersTest {

Step 3: Write the main unit test

   public void test<Site>Rip() throws IOException {
        <Site>Ripper ripper = new DribbbleRipper(new URL(<URL the ripper supports>));
        testRipper(ripper);
    }

You should do this for every album type that the ripper supports

Step 4: Write tests for getGID and getAlbumTitle // Optional!

Althought not required you should write a unit test for getGID and getAlbumbTitle (If your ripper supports getAlbumbTitle)

An example of both of these can be found in the zizki ripper

    public void testGetGID() throws IOException {
        URL url = new URL("http://zizki.com/dee-chorde/we-got-spirit");
        ZizkiRipper ripper = new ZizkiRipper(url);
        assertEquals("dee-chorde", ripper.getGID(url));
    }

    public void testAlbumTitle() throws IOException {
        URL url = new URL("http://zizki.com/dee-chorde/we-got-spirit");
        ZizkiRipper ripper = new ZizkiRipper(url);
        assertEquals("zizki_Dee Chorde_We Got Spirit", ripper.getAlbumTitle(url));
    }