Assumptions Flashcards

1
Q

Assumptions

A

Assumptions are typically used whenever it does not make sense to continue the execution of a given test method, for example, if the test depends on something that does not exist in the current runtime environment. In the test report, these tests will be marked as aborted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Difference b/w Assumptions and Assertions

A

Assert to fail a test if something goes wrong
A failed assumption means you don’t run the test because something you assumed to be true is not true and so you just skip the test.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Assumptions.abort()

A

The abort() method aborts the test with or without a message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Assumptions.assumeTrue()

A

@Test
void testOnDev() {
System.setProperty(“ENV”, “DEV”);
Assumptions.assumeTrue(“DEV”.equals(System.getProperty(“ENV”)));
//remainder of test will proceed
}

@Test
void testOnProd(){
	System.setProperty("ENV", "PROD");
	Assumptions.assumeTrue("DEV".equals(System.getProperty("ENV")), AppTest::message);
	//remainder of test will be aborted
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Assumptions.assumeFalse()

A

The assumeFalse() method validates the given assumption to false and if the assumption is false – test proceed, otherwise, test execution is aborted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Assertions.assumingThat()

A

This method executes the supplied Executable, but only if the supplied assumption is valid.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly