How assert if String is present in a List of Strings?

52 views Asked by At

How would I create a junit test that checks if given String is present in List of String?

I was thinking using contains but not sure if I am on the right path or not.

1

There are 1 answers

0
Martin C. On

Yes, you can do it like that (there are other ways):

@Test
public void testContains() {
    var list = List.of("a", "b", "c");
    assertTrue(list.contains("a"));
}