Added in API level 1
Deprecated in API level 24

MoreAsserts


class MoreAsserts
kotlin.Any
   ↳ android.test.MoreAsserts

Contains additional assertion methods not found in JUnit.

Summary

Public methods
static Unit
assertAssignableFrom(expected: Class<*>!, actual: Any!)

Asserts that the class expected is assignable from the object actual.

static Unit
assertAssignableFrom(expected: Class<*>!, actual: Class<*>!)

Asserts that class expected is assignable from the class actual.

static MatchResult!
assertContainsRegex(message: String!, expectedRegex: String!, actual: String!)

Asserts that expectedRegex matches any substring of actual and fails with message if it does not.

static MatchResult!
assertContainsRegex(expectedRegex: String!, actual: String!)

Variant of assertContainsRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

static Unit
assertContentsInAnyOrder(message: String!, actual: MutableIterable<*>!, vararg expected: Any!)

Asserts that actual contains precisely the elements expected, but in any order.

static Unit
assertContentsInAnyOrder(actual: MutableIterable<*>!, vararg expected: Any!)

Variant of assertContentsInAnyOrder(String, Iterable, Object.

static Unit
assertContentsInOrder(message: String!, actual: MutableIterable<*>!, vararg expected: Any!)

Asserts that actual contains precisely the elements expected, and in the same order.

static Unit
assertContentsInOrder(actual: MutableIterable<*>!, vararg expected: Any!)

Variant of assertContentsInOrder(String, Iterable, Object.

static Unit
assertEmpty(message: String!, iterable: MutableIterable<*>!)

Asserts that iterable is empty.

static Unit

Variant of assertEmpty(java.lang.String,java.lang.Iterable) using a generic message.

static Unit
assertEmpty(message: String!, map: MutableMap<*, *>!)

Asserts that map is empty.

static Unit
assertEmpty(map: MutableMap<*, *>!)

Variant of assertEmpty(java.lang.String,java.util.Map) using a generic message.

static Unit
assertEquals(message: String!, expected: ByteArray!, actual: ByteArray!)

Asserts that array actual is the same size and every element equals those in array expected.

static Unit
assertEquals(expected: ByteArray!, actual: ByteArray!)

Asserts that array actual is the same size and every element equals those in array expected.

static Unit
assertEquals(message: String!, expected: IntArray!, actual: IntArray!)

Asserts that array actual is the same size and every element equals those in array expected.

static Unit
assertEquals(expected: IntArray!, actual: IntArray!)

Asserts that array actual is the same size and every element equals those in array expected.

static Unit
assertEquals(message: String!, expected: DoubleArray!, actual: DoubleArray!)

Asserts that array actual is the same size and every element equals those in array expected.

static Unit
assertEquals(expected: DoubleArray!, actual: DoubleArray!)

Asserts that array actual is the same size and every element equals those in array expected.

static Unit
assertEquals(message: String!, expected: Array<Any!>!, actual: Array<Any!>!)

Asserts that array actual is the same size and every element is the same as those in array expected.

static Unit
assertEquals(expected: Array<Any!>!, actual: Array<Any!>!)

Asserts that array actual is the same size and every element is the same as those in array expected.

static Unit
assertEquals(message: String!, expected: MutableSet<*>!, actual: MutableSet<*>!)

Asserts that two sets contain the same elements.

static Unit
assertEquals(expected: MutableSet<*>!, actual: MutableSet<*>!)

Asserts that two sets contain the same elements.

static MatchResult!
assertMatchesRegex(message: String!, expectedRegex: String!, actual: String!)

Asserts that expectedRegex exactly matches actual and fails with message if it does not.

static MatchResult!
assertMatchesRegex(expectedRegex: String!, actual: String!)

Variant of assertMatchesRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

static Unit
assertNotContainsRegex(message: String!, expectedRegex: String!, actual: String!)

Asserts that expectedRegex does not match any substring of actual, and fails with message if it does.

static Unit
assertNotContainsRegex(expectedRegex: String!, actual: String!)

Variant of assertNotContainsRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

static Unit
assertNotEmpty(message: String!, iterable: MutableIterable<*>!)

Asserts that iterable is not empty.

static Unit

Variant of assertNotEmpty(String, Iterable) using a generic message.

static Unit
assertNotEmpty(message: String!, map: MutableMap<*, *>!)

Asserts that map is not empty.

static Unit
assertNotEmpty(map: MutableMap<*, *>!)

Variant of assertNotEmpty(java.lang.String,java.util.Map) using a generic message.

static Unit
assertNotEqual(message: String!, unexpected: Any!, actual: Any!)

Asserts that actual is not equal unexpected, according to both == and Object#equals.

static Unit
assertNotEqual(unexpected: Any!, actual: Any!)

Variant of assertNotEqual(java.lang.String,java.lang.Object,java.lang.Object) using a generic message.

static Unit
assertNotMatchesRegex(message: String!, expectedRegex: String!, actual: String!)

Asserts that expectedRegex does not exactly match actual, and fails with message if it does.

static Unit
assertNotMatchesRegex(expectedRegex: String!, actual: String!)

Variant of assertNotMatchesRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

static Unit
checkEqualsAndHashCodeMethods(message: String!, lhs: Any!, rhs: Any!, expectedResult: Boolean)

Utility for testing equals() and hashCode() results at once.

static Unit
checkEqualsAndHashCodeMethods(lhs: Any!, rhs: Any!, expectedResult: Boolean)

Variant of checkEqualsAndHashCodeMethods(String,Object,Object,boolean...)} using a generic message.

Public methods

assertAssignableFrom

Added in API level 1
static fun assertAssignableFrom(
    expected: Class<*>!,
    actual: Any!
): Unit

Deprecated: Deprecated in Java.

Asserts that the class expected is assignable from the object actual. This verifies expected is a parent class or a interface that actual implements.

assertAssignableFrom

Added in API level 1
static fun assertAssignableFrom(
    expected: Class<*>!,
    actual: Class<*>!
): Unit

Deprecated: Deprecated in Java.

Asserts that class expected is assignable from the class actual. This verifies expected is a parent class or a interface that actual implements.

assertContainsRegex

Added in API level 1
static fun assertContainsRegex(
    message: String!,
    expectedRegex: String!,
    actual: String!
): MatchResult!

Deprecated: Deprecated in Java.

Asserts that expectedRegex matches any substring of actual and fails with message if it does not. The Matcher is returned in case the test needs access to any captured groups. Note that you can also use this for a literal string, by wrapping your expected string in Pattern#quote.

assertContainsRegex

Added in API level 1
static fun assertContainsRegex(
    expectedRegex: String!,
    actual: String!
): MatchResult!

Deprecated: Deprecated in Java.

Variant of assertContainsRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

assertContentsInAnyOrder

Added in API level 1
static fun assertContentsInAnyOrder(
    message: String!,
    actual: MutableIterable<*>!,
    vararg expected: Any!
): Unit

Deprecated: Deprecated in Java.

Asserts that actual contains precisely the elements expected, but in any order.

assertContentsInAnyOrder

Added in API level 1
static fun assertContentsInAnyOrder(
    actual: MutableIterable<*>!,
    vararg expected: Any!
): Unit

Deprecated: Deprecated in Java.

Variant of assertContentsInAnyOrder(String, Iterable, Object...) using a generic message.

assertContentsInOrder

Added in API level 1
static fun assertContentsInOrder(
    message: String!,
    actual: MutableIterable<*>!,
    vararg expected: Any!
): Unit

Deprecated: Deprecated in Java.

Asserts that actual contains precisely the elements expected, and in the same order.

assertContentsInOrder

Added in API level 1
static fun assertContentsInOrder(
    actual: MutableIterable<*>!,
    vararg expected: Any!
): Unit

Deprecated: Deprecated in Java.

Variant of assertContentsInOrder(String, Iterable, Object...) using a generic message.

assertEmpty

Added in API level 1
static fun assertEmpty(
    message: String!,
    iterable: MutableIterable<*>!
): Unit

Deprecated: Deprecated in Java.

Asserts that iterable is empty.

assertEmpty

Added in API level 1
static fun assertEmpty(iterable: MutableIterable<*>!): Unit

Deprecated: Deprecated in Java.

Variant of assertEmpty(java.lang.String,java.lang.Iterable) using a generic message.

assertEmpty

Added in API level 1
static fun assertEmpty(
    message: String!,
    map: MutableMap<*, *>!
): Unit

Deprecated: Deprecated in Java.

Asserts that map is empty.

assertEmpty

Added in API level 1
static fun assertEmpty(map: MutableMap<*, *>!): Unit

Deprecated: Deprecated in Java.

Variant of assertEmpty(java.lang.String,java.util.Map) using a generic message.

assertEquals

Added in API level 1
static fun assertEquals(
    message: String!,
    expected: ByteArray!,
    actual: ByteArray!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element equals those in array expected. On failure, message indicates specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    expected: ByteArray!,
    actual: ByteArray!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element equals those in array expected. On failure, message indicates specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    message: String!,
    expected: IntArray!,
    actual: IntArray!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element equals those in array expected. On failure, message indicates first specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    expected: IntArray!,
    actual: IntArray!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element equals those in array expected. On failure, message indicates first specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    message: String!,
    expected: DoubleArray!,
    actual: DoubleArray!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element equals those in array expected. On failure, message indicates first specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    expected: DoubleArray!,
    actual: DoubleArray!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element equals those in array expected. On failure, message indicates first specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    message: String!,
    expected: Array<Any!>!,
    actual: Array<Any!>!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element is the same as those in array expected. Note that this uses equals() instead of == to compare the objects. null will be considered equal to null (unlike SQL). On failure, message indicates first specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    expected: Array<Any!>!,
    actual: Array<Any!>!
): Unit

Deprecated: Deprecated in Java.

Asserts that array actual is the same size and every element is the same as those in array expected. Note that this uses == instead of equals() to compare the objects. On failure, message indicates first specific element mismatch.

assertEquals

Added in API level 1
static fun assertEquals(
    message: String!,
    expected: MutableSet<*>!,
    actual: MutableSet<*>!
): Unit

Deprecated: Deprecated in Java.

Asserts that two sets contain the same elements.

assertEquals

Added in API level 1
static fun assertEquals(
    expected: MutableSet<*>!,
    actual: MutableSet<*>!
): Unit

Deprecated: Deprecated in Java.

Asserts that two sets contain the same elements.

assertMatchesRegex

Added in API level 1
static fun assertMatchesRegex(
    message: String!,
    expectedRegex: String!,
    actual: String!
): MatchResult!

Deprecated: Deprecated in Java.

Asserts that expectedRegex exactly matches actual and fails with message if it does not. The MatchResult is returned in case the test needs access to any captured groups. Note that you can also use this for a literal string, by wrapping your expected string in Pattern#quote.

assertMatchesRegex

Added in API level 1
static fun assertMatchesRegex(
    expectedRegex: String!,
    actual: String!
): MatchResult!

Deprecated: Deprecated in Java.

Variant of assertMatchesRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

assertNotContainsRegex

Added in API level 1
static fun assertNotContainsRegex(
    message: String!,
    expectedRegex: String!,
    actual: String!
): Unit

Deprecated: Deprecated in Java.

Asserts that expectedRegex does not match any substring of actual, and fails with message if it does. Note that you can also use this for a literal string, by wrapping your expected string in Pattern#quote.

assertNotContainsRegex

Added in API level 1
static fun assertNotContainsRegex(
    expectedRegex: String!,
    actual: String!
): Unit

Deprecated: Deprecated in Java.

Variant of assertNotContainsRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

assertNotEmpty

Added in API level 1
static fun assertNotEmpty(
    message: String!,
    iterable: MutableIterable<*>!
): Unit

Deprecated: Deprecated in Java.

Asserts that iterable is not empty.

assertNotEmpty

Added in API level 1
static fun assertNotEmpty(iterable: MutableIterable<*>!): Unit

Deprecated: Deprecated in Java.

Variant of assertNotEmpty(String, Iterable) using a generic message.

assertNotEmpty

Added in API level 1
static fun assertNotEmpty(
    message: String!,
    map: MutableMap<*, *>!
): Unit

Deprecated: Deprecated in Java.

Asserts that map is not empty.

assertNotEmpty

Added in API level 1
static fun assertNotEmpty(map: MutableMap<*, *>!): Unit

Deprecated: Deprecated in Java.

Variant of assertNotEmpty(java.lang.String,java.util.Map) using a generic message.

assertNotEqual

Added in API level 1
static fun assertNotEqual(
    message: String!,
    unexpected: Any!,
    actual: Any!
): Unit

Deprecated: Deprecated in Java.

Asserts that actual is not equal unexpected, according to both == and Object#equals.

assertNotEqual

Added in API level 1
static fun assertNotEqual(
    unexpected: Any!,
    actual: Any!
): Unit

Deprecated: Deprecated in Java.

Variant of assertNotEqual(java.lang.String,java.lang.Object,java.lang.Object) using a generic message.

assertNotMatchesRegex

Added in API level 1
static fun assertNotMatchesRegex(
    message: String!,
    expectedRegex: String!,
    actual: String!
): Unit

Deprecated: Deprecated in Java.

Asserts that expectedRegex does not exactly match actual, and fails with message if it does. Note that you can also use this for a literal string, by wrapping your expected string in Pattern#quote.

assertNotMatchesRegex

Added in API level 1
static fun assertNotMatchesRegex(
    expectedRegex: String!,
    actual: String!
): Unit

Deprecated: Deprecated in Java.

Variant of assertNotMatchesRegex(java.lang.String,java.lang.String,java.lang.String) using a generic message.

checkEqualsAndHashCodeMethods

Added in API level 1
static fun checkEqualsAndHashCodeMethods(
    message: String!,
    lhs: Any!,
    rhs: Any!,
    expectedResult: Boolean
): Unit

Deprecated: Deprecated in Java.

Utility for testing equals() and hashCode() results at once. Tests that lhs.equals(rhs) matches expectedResult, as well as rhs.equals(lhs). Also tests that hashCode() return values are equal if expectedResult is true. (hashCode() is not tested if expectedResult is false, as unequal objects can have equal hashCodes.)

Parameters
lhs Any!: An Object for which equals() and hashCode() are to be tested.
rhs Any!: As lhs.
expectedResult Boolean: True if the objects should compare equal, false if not.

checkEqualsAndHashCodeMethods

Added in API level 1
static fun checkEqualsAndHashCodeMethods(
    lhs: Any!,
    rhs: Any!,
    expectedResult: Boolean
): Unit

Deprecated: Deprecated in Java.

Variant of checkEqualsAndHashCodeMethods(String,Object,Object,boolean...)} using a generic message.