Interface AppFixture
-
public interface AppFixture
Use the AppFixture to temporary change the active environment or variables of an application in tests.
Changes are rollbacked automatically to the previous value after the test.
To use the AppFixture annotate your test class with either the
IvyTest
orIvyProcessTest
annotation. Then add the AppFixture as parameter to anyTest
,BeforeAll
,BeforeEach
,AfterEach
,AfterAll
methods or the constructor of the test class.Changes made in
BeforeAll
andAfterAll
methods are rollbacked after the execution of the test class. Changes made inBeforeEach
,AfterEach
andTest
methods are rollbacked after the execution of each test.Example:
@IvyTest class Test { @Test void test(AppFixture fixture) { assertThat(Ivy.var().get("limit")).isEqualTo("150"); fixture.var("limit", "300"); assertThat(Ivy.var().get("limit")).isEqualTo("300"); }
- Since:
- 9.1
- See Also:
IvyTest
,IvyProcessTest
,Ivy
- API:
- This is a public API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
environment(String activeEnvironment)
Changes the active environment for a test.void
loginUser(IUser user)
Login with an existing user.void
loginUser(String userName)
Login with an existing user.void
var(String name, String value)
Changes the value of a variable for a test.
-
-
-
Method Detail
-
environment
void environment(String activeEnvironment)
Changes the active environment for a test. The active environment will be automatically rollbacked to the previous environment when the test has been executed.
Example:
@Test void test(AppFixture fixture) { fixture.environment("Customer A"); ... }
- Parameters:
activeEnvironment
-- API:
- This public API is available in Java.
-
var
void var(String name, String value)
Changes the value of a variable for a test. The value of the variable will be automatically rollbacked to the previous value when the test has been executed.
Example:
@Test void test(AppFixture fixture) { assertThat(Ivy.var().get("limit")).isEqualTo("150"); fixture.var("limit", "300"); assertThat(Ivy.var().get("limit")).isEqualTo("300"); }
- Parameters:
name
- the name of the variablevalue
- the new value of the variable- API:
- This public API is available in Java.
-
loginUser
void loginUser(IUser user)
Login with an existing user. After the test the user is automatically logged out.
Example:
@Test void test(AppFixture fixture, @Named("James Bond") IUser user) { fixture.loginUser(user); ... }
- Parameters:
user
- the user to log in- API:
- This public API is available in Java.
-
loginUser
void loginUser(String userName)
Login with an existing user. After the test the user is automatically logged out.
Example:
@Test void test(AppFixture fixture) { fixture.loginUser("James Bond"); ... }
- Parameters:
userName
- the name of the user- API:
- This public API is available in Java.
-
-