dime-worldbank/Disease-Modelling-SSA

unit testing

Opened this issue · 3 comments

swise5 commented

we have no unit testing suite, which is bad practice and makes merging the branches hazardous.

swise5 commented

Reviewing best practices (eg Baeldung and Unit Testing Principles, Practices, and Patterns by Khorikov, restructuring the project directory seems necessary. The question of how to ensure that the python scripts and the java project are made maximally accessible is unclear to me and I'm going to do a bit more reading about it.

swise5 commented

I've done a lot of refactoring, and it's probably worth us having a review session on how to rebase branches for merging purposes!
In any case, the main branch now has a basic testing suite setup. I'll work on developing it further. For the time being, I am not making use of gradle - but in the future it would be helpful in terms of automatically jarring the code, etc.

Go through and make these tests parameterized. e.g.

import static org.junit.Assert.assertTrue;

import java.util.Arrays;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(Parameterized.class)
public class ParametrizedTest {

private final String text;
private final int number;

public ParametrizedTest(String text, int number) {
    this.text = text;
    this.number = number;
}

@Test
public void shouldContainNumber() {
    assertTrue(text.contains(String.valueOf(number)));
}

@Parameterized.Parameters
public static Iterable<Object[]> params() {
    return Arrays.asList(
            new Object[][]{
                    {"test string 1", 1},
                    {"test string 2", 2}
            }
    );
}

}