/* * Copyright 2015-2017 the original author or authors. * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution and is available at * * http://www.eclipse.org/legal/epl-v10.html */ package org.junit.jupiter.api; import static org.junit.jupiter.api.AssertionTestUtils.assertMessageEquals; import static org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError; import static org.junit.jupiter.api.Assertions.assertTrue; import org.opentest4j.AssertionFailedError; /** * Unit tests for JUnit Jupiter {@link Assertions}. * * @since 5.0 */ class AssertionsAssertTrueTests { @Test void assertTrueWithBooleanTrue() { assertTrue(true); } @Test void assertTrueWithBooleanSupplierTrue() { assertTrue(() -> true); } @Test void assertTrueWithBooleanTrueAndString() { assertTrue(true, "test"); } @Test void assertTrueWithBooleanFalse() { try { assertTrue(false); expectAssertionFailedError(); } catch (AssertionFailedError ex) { assertMessageEquals(ex, ""); } } @Test void assertTrueWithBooleanFalseAndString() { try { assertTrue(false, "test"); expectAssertionFailedError(); } catch (AssertionFailedError ex) { assertMessageEquals(ex, "test"); } } @Test void assertTrueWithBooleanSupplierFalseAndString() { try { assertTrue(() -> false, "test"); expectAssertionFailedError(); } catch (AssertionFailedError ex) { assertMessageEquals(ex, "test"); } } @Test void assertTrueWithBooleanSupplierFalseAndMessageSupplier() { try { assertTrue(() -> false, () -> "test"); expectAssertionFailedError(); } catch (AssertionFailedError ex) { assertMessageEquals(ex, "test"); } } }