public class MultiUserTestRunner
extends org.junit.runners.Suite
Test runner for executing tests with multiple producer-consumer combinations. Producer
is the user creating a resource e.g. project or a customer. Consumer is the user who
later uses/edits/deletes the previously created resource. Used with JUnit's
RunWith
annotation.
MultiUserTestRunner requires the test class to have RunWithUsers
annotation which
will define with what users the tests are executed. To configure the test runner use
MultiUserTestConfig
annotation.
There are two different type of definitions that can be used: roles and users. Roles create a new user to DB with the given role. Users use existing users that are found in the DB. The syntax is [role|user]:[role name|username] e.g. "role:ROLE_ADMIN" or "user:username".
There are also two special definitions that can be used for test consumers (not producers): RunWithUsers.PRODUCER
and
RunWithUsers.WITH_PRODUCER_ROLE
. RunWithUsers.PRODUCER
uses
the the same user as the resource was generated. RunWithUsers.WITH_PRODUCER_ROLE
creates a new user with the same role as the producer had.
There is also a special role RunWithUsers.ANONYMOUS
both for
the producer and the consumer. This means that the current consumer or producer isn't logged in.
If no users are defined RunWithUsers.WITH_PRODUCER_ROLE
will be used as the default
consumer definition. Producers can't use RunWithUsers.WITH_PRODUCER_ROLE
or
RunWithUsers.PRODUCER
roles since those roles are tied to the current
producer role.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ROLE_PREFIX |
static java.lang.String |
USER_PREFIX |
Constructor and Description |
---|
MultiUserTestRunner(java.lang.Class<?> klass) |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<org.junit.runner.Runner> |
getChildren() |
childrenInvoker, classBlock, classRules, collectInitializationErrors, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, isIgnored, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses
public static final java.lang.String ROLE_PREFIX
public static final java.lang.String USER_PREFIX