Quick Start
This section guides you through the process of getting Proctor and implementing a simple A/B test.
Get Proctor
Pulling from maven repository
Add these dependencies to your pom.xml:
<dependencies>
<!-- use this dependency only if your environment is providing tomcat libraries
<dependency>
<groupId>com.indeed</groupId>
<artifactId>proctor-tomcat-deps-provided</artifactId>
<version>1.0</version>
<type>pom</type>
</dependency>
-->
<dependency>
<groupId>com.indeed</groupId>
<artifactId>proctor-common</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.indeed</groupId>
<artifactId>proctor-consumer</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.indeed</groupId>
<artifactId>proctor-codegen</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.indeed</groupId>
<artifactId>proctor-maven-plugin</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.indeed</groupId>
<artifactId>util-core</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Building from source (using maven)
Use git to clone https://github.com/indeedeng/proctor, and run mvn install to build.
Implement an A/B test with Proctor
For this process, we’ll use an example similar to the https://github.com/indeedeng/proctor-demo reference implementation project. You’ll run an A/B test of a new background color for your web application. The example uses maven to build and the Proctor maven plugin to generate Proctor convenience classes.
Specifying the test
- Write the JSON specification for your test and put it into a Java-like package structure under
src/main/proctor/. For this example, name the packageorg.example.proctorand useExampleGroupsin generated Java class names. - Create the file
src/main/proctor/org/example/proctor/ExampleGroups.jsonwith this content:
The result is a single test bgcolortst with five buckets: inactive, altcolor1, altcolor2, altcolor3, altcolor4.
Setting up the maven plugin and generate code
-
Edit your
pom.xmlto enable the Proctor maven plugin:<build> <plugins> <!-- add this plugin definition --> <plugin> <groupId>com.indeed</groupId> <artifactId>proctor-maven-plugin</artifactId> <version>1.0</version> <executions> <execution> <id>proctor-generate</id> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> -
To generate the Proctor convenience classes, run
mvn proctor:generate, which createsExampleGroups.javaandExampleGroupsManager.javaintarget/generated-sources/proctor/org/example/proctor/.
Creating your initial test definition
In the test specification you created, you set up 4 test buckets and one inactive bucket. For this example, you’ll put 10% of your users in each test bucket. Leaving space between each bucket allows you to increase them later without moving users between buckets. Your definition would be:
| altcolor1 | inactive | altcolor2 | inactive | altcolor3 | inactive | altcolor4 |
|---|---|---|---|---|---|---|
| 10% | 20% | 10% | 20% | 10% | 20% | 10% |
-
Create a file called
proctor-definition.jsonwith this content: -
Load this definition from the file system as your test matrix.
Writing some code
-
Load your specification (from the classpath) and use it to load your test matrix.
-
Use the Proctor object to get the generated convenience class objects. You’ll need to provide a user unique id, typically stored in a cookie for web applications, since this is a
USERtest.
You can now use the ExampleGroups object in your Java code or your view templates.
Java example
JSP example
Testing your groups
Test the different buckets by appending the query param prforceGroups. For example, ?prforceGroups=bgcolortst1 would temporarily put you into bucket 1 of the bgcolortst test, and would set a prforceGroups cookie to keep you in that group for the length of your browser session.