Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit testing #18

Open
swise5 opened this issue Jul 29, 2023 · 3 comments
Open

unit testing #18

swise5 opened this issue Jul 29, 2023 · 3 comments
Assignees

Comments

@swise5
Copy link
Collaborator

swise5 commented Jul 29, 2023

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

@swise5 swise5 self-assigned this Jul 29, 2023
@swise5
Copy link
Collaborator Author

swise5 commented Jul 29, 2023

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
Copy link
Collaborator Author

swise5 commented Jul 29, 2023

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.

@RobertManningSmith
Copy link
Collaborator

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}
            }
    );
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants