Wednesday 4 April 2018

Hamcrest: isOneOf: Matches of altest one element matches

By using ‘isOneOf’ method, you can create a matcher that matches when the examined object is equal to one of the specified elements.

Ex
assertThat("India", isOneOf("Africa", "India", "Sri Lanka"));

TestApp.java

package com.sample.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isOneOf;

import org.junit.Test;

public class TestApp {

 @Test
 public void testmethod() {
  assertThat("India", isOneOf("Africa", "India", "Sri Lanka"));
 }
}



Previous                                                 Next                                                 Home

No comments:

Post a Comment