Java Assert assertContains(String needle, String haystack)

Here you can find the source of assertContains(String needle, String haystack)

Description

assert Contains

License

Apache License

Declaration

public static void assertContains(String needle, String haystack) 

Method Source Code

//package com.java2s;
/* Copyright 2012 predic8 GmbH, www.predic8.com
    // w ww .  j a  v  a 2 s  .  c o  m
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License. */

public class Main {
    public static void assertContains(String needle, String haystack) {
        if (haystack.contains(needle))
            return;
        throw new AssertionError("The string '" + haystack + "' does not contain '" + needle + "'.");
    }
}

Related

  1. assertComparison(T actual, T expected)
  2. assertCond(boolean b)
  3. assertCondition(boolean condition, String message)
  4. assertCondition(boolean condition, String msg)
  5. assertContains(final String string, final String content)
  6. assertDescriptorName(String key)
  7. assertDidNotThrow(final Runnable r)
  8. assertDifferentInstance(final Object o1, final Object o2)
  9. assertDotted(String name)