-2

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
  • 1
    You have the solution. Edit your Question to express your reservations or concerns. Commented Feb 8, 2024 at 7:55

1 Answer 1

2

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"));
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.