Package de.monticore.runtime.junit
Class MCAssertions
- java.lang.Object
-
- de.monticore.runtime.junit.MCAssertions
-
public class MCAssertions extends java.lang.ObjectMCAssertions is a collection of utility methods that support asserting conditions in MontiCore tests. Unless otherwise noted, a failed assertion will throw anAssertionFailedErroror a subclass thereof.
-
-
Constructor Summary
Constructors Constructor Description MCAssertions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static de.se_rwth.commons.logging.FindingassertHasFinding()Asserts that at least one Finding is present and removes that Finding from the Log.static de.se_rwth.commons.logging.FindingassertHasFinding(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)Asserts that at least one Finding matches the predicate and removes that Finding from the Log.static de.se_rwth.commons.logging.FindingassertHasFinding(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate, java.lang.String message)Asserts that at least one Finding matches the predicate and removes that Finding from the Log.static java.util.Collection<de.se_rwth.commons.logging.Finding>assertHasFindings(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)Asserts that at least one Finding matches the predicate and removes all matching Findings from the Logstatic java.util.Collection<de.se_rwth.commons.logging.Finding>assertHasFindings(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate, java.lang.String message)Asserts that at least one Finding matches the predicate and removes all matching Findings from the Logstatic java.util.Collection<de.se_rwth.commons.logging.Finding>assertHasFindingsStartingWith(java.lang.String expectedPrefix)Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Logstatic java.util.Collection<de.se_rwth.commons.logging.Finding>assertHasFindingsStartingWith(java.lang.String expectedPrefix, java.lang.String message)Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Logstatic de.se_rwth.commons.logging.FindingassertHasFindingStartingWith(java.lang.String expectedPrefix)Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Logstatic de.se_rwth.commons.logging.FindingassertHasFindingStartingWith(java.lang.String expectedPrefix, java.lang.String message)Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Logstatic voidassertNoFindings()Asserts that no findings are present.static voidassertNoFindings(java.lang.String message)Asserts that no findings are present.static <V> VfailAndPrintFindings()Fails a test.static <V> VfailAndPrintFindings(java.lang.String message)Fails a test with the given failure message.
-
-
-
Method Detail
-
assertHasFindingStartingWith
public static de.se_rwth.commons.logging.Finding assertHasFindingStartingWith(java.lang.String expectedPrefix, java.lang.String message)Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Log- Parameters:
expectedPrefix- the expected prefixmessage- the message to fail with iff no finding was found- Returns:
- returns the found Finding
- See Also:
assertHasFinding(Predicate, String)
-
assertHasFindingStartingWith
public static de.se_rwth.commons.logging.Finding assertHasFindingStartingWith(java.lang.String expectedPrefix)
Asserts that at least one Finding starts with the expected prefix and removes that Finding from the Log- Parameters:
expectedPrefix- the expected prefix- Returns:
- returns the found Finding
- See Also:
assertHasFinding(Predicate)
-
assertHasFindingsStartingWith
public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindingsStartingWith(java.lang.String expectedPrefix, java.lang.String message)Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Log- Parameters:
expectedPrefix- the expected prefixmessage- the message to fail with iff no findings were found- Returns:
- returns the list of found Findings
- See Also:
assertHasFindings(Predicate, String)
-
assertHasFindingsStartingWith
public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindingsStartingWith(java.lang.String expectedPrefix)
Asserts that at least one Finding starts with the expected prefix and removes all matching Findings from the Log- Parameters:
expectedPrefix- the expected prefix- Returns:
- returns the list of found Findings
- See Also:
assertHasFinding(Predicate)
-
assertHasFinding
public static de.se_rwth.commons.logging.Finding assertHasFinding(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate, java.lang.String message)Asserts that at least one Finding matches the predicate and removes that Finding from the Log. If multiple Findings match, only the first of them will be removed.- Parameters:
predicate- the predicatemessage- the message to fail with iff no finding was found- Returns:
- returns the found Finding
-
assertHasFinding
public static de.se_rwth.commons.logging.Finding assertHasFinding(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)
Asserts that at least one Finding matches the predicate and removes that Finding from the Log. If multiple Findings match, only the first of them will be removed.- Parameters:
predicate- the predicate- Returns:
- returns the found Finding
-
assertHasFinding
public static de.se_rwth.commons.logging.Finding assertHasFinding()
Asserts that at least one Finding is present and removes that Finding from the Log. If multiple Findings match, only the first of them will be removed. This method should NOT be used in conjunction with CoCo-Tests.- Returns:
- returns the found Finding
-
assertHasFindings
public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindings(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate, java.lang.String message)Asserts that at least one Finding matches the predicate and removes all matching Findings from the Log- Parameters:
predicate- the predicatemessage- the message to fail with iff no findings were found- Returns:
- returns the list of found Findings
-
assertHasFindings
public static java.util.Collection<de.se_rwth.commons.logging.Finding> assertHasFindings(java.util.function.Predicate<de.se_rwth.commons.logging.Finding> predicate)
Asserts that at least one Finding matches the predicate and removes all matching Findings from the Log- Parameters:
predicate- the predicate- Returns:
- returns the list of found Findings
-
assertNoFindings
public static void assertNoFindings(java.lang.String message)
Asserts that no findings are present.- Parameters:
message- the message to fail with iff findings were found
-
assertNoFindings
public static void assertNoFindings()
Asserts that no findings are present.
-
failAndPrintFindings
public static <V> V failAndPrintFindings()
Fails a test. Additionally, Lists the state of Log-Findings. See Javadoc forAssertions.fail(String, Throwable)for an explanation of this method's generic return type V.- Returns:
- nothing
-
failAndPrintFindings
public static <V> V failAndPrintFindings(java.lang.String message)
Fails a test with the given failure message. Additionally, Lists the state of Log-Findings. See Javadoc forAssertions.fail(String, Throwable)for an explanation of this method's generic return type V.- Parameters:
message- message to print- Returns:
- nothing
-
-