Accept an AI edit to a Workday Studio assembly only after the same AUnit tests pass that passed before the edit. AUnit is Studio’s framework for unit-testing assemblies. You write the tests in Java, in the assembly project, starting from a skeleton Studio creates. An assertion that fails aborts the assembly and reports a failure. An unexpected exception aborts the assembly and reports an error. Those two outcomes are the gate. A diff that “looks like the XSLT you asked for” is not.
This is a Studio practice. Workday’s Developer Agent overview describes Extend apps, pages, business objects, scripts, and queries. It does not describe Studio assemblies or AUnit. If an assistant outside Studio proposes a change to an assembly file, you still paste or merge it in Studio and run AUnit there. Nothing on the AUnit pages says an assistant runs these tests for you.
What a test contains
Every AUnit test carries @AssemblyTest. That annotation marks the class as an AUnit test and ties it to the assembly project. Workday’s sample is @AssemblyTest(project = "AUnitTrainer", displayLabel = "Citizens of the Cloud"). The project attribute is the one that binds the test. The display label is optional in the sense that the minimal example Workday also prints is @AssemblyTest(project = "AUnitTrainer").
A method marked @UnitTest is one case. startComponent is where that case begins in the assembly. The body puts a fixture on the message. Workday’s sample loads test/simple-input.xml as text/xml onto message part 0 with setMessagePart.
Assertions are Boolean conditions. You hang them on the assembly with one of these annotations:
| Annotation | When it runs | What people use it for |
|---|---|---|
Annotation@AssertBefore |
When it runsBefore a named component or step | What people use it forThe message is still what you think it is before a step mutates it |
Annotation@AssertAfter |
When it runsAfter a named component or step | What people use it forThe root part matches the expected XML, or an XPath returns the expected text |
Annotation@AssertAfterCompletion |
When it runsAfter the assembly finishes | What people use it forA property such as an error count has the expected value |
Annotation@AtComponent |
When it runsWhen execution reaches a named component | What people use it forReplace a call you cannot make from a unit test, or stop the chain |
@AssertAfter(id = "Simple-Mediation", step = "transform") is the sample that compares the message part to test/simple-expected.xml using Comparator.dom. A second sample checks XPath: the worker name is Ace Developer and the hire date is 2010-07-27-07:00. Copy that shape. Point id and step at components that exist in your assembly. An assertion aimed at a step the AI renamed is a false failure, or it never runs.
@AtComponent returns an action. The sample for a component id Next-Thing returns StandardAction of type terminate, which stops the chain there. The sample for Get-Workers loads a fixture XML and returns type mock, so the test never calls Workday for workers. Mock the outbound call. Do not point a unit test at a tenant and call it AUnit.
If the assertion fails, Studio reports a failure. If something else throws, Studio reports an error. When you read a red run, keep those apart. A failure means the XML or the value was wrong. An error means the assembly or the test threw. An AI edit that drops a namespace often shows up as an error in the comparison, or as a failure against the expected document. Read which one you got before you prompt again.
Create the skeleton once
Workday’s skeleton task creates the Java class inside an assembly project. The parts that page states in words you can follow:
- The project is an Assembly project with Java support.
- The project name must not contain spaces.
- The class extends
com.workday.aunit.AssemblyTestCase. You choose that superclass when you create the class. - You give the class a package and a name.
- Studio opens the skeleton in the Java editor. The test then lives under the project in Project Explorer.
The skeleton page’s intermediate field labels did not come through as a complete click-path in a fetch on November 16, 2026. Use the labels Studio shows on that task, and use the superclass name above. Do not invent a menu name this guide does not have.
Put fixtures next to the test in the paths you pass to setMessagePart and getTestResourceInputStream, such as test/simple-input.xml and test/simple-expected.xml. Commit the expected file. An assistant that “updates the sample output” has changed the test, not the assembly. Review that diff as a test change and reject it unless the behavior change is intentional.
Run it before and after the edit
Workday’s sample project is AUnit 101. It contains 8 processing chains. You run it from the assembly in Studio, then open the results. Use that sample once if you have never seen a green AUnit run, so you know what Studio looks like when the framework is healthy.
For your own assembly:
- Run the existing AUnit tests and keep the green result. If there are no tests, write the skeleton for the component you are about to let an assistant change. A missing test is not a pass.
- Give the assistant the component id and the step id, and the assertion you intend to keep. Ask it not to rename
@AssertAftertargets and not to edit files under the test fixture path. - Merge the assembly change in Studio. Do not merge a surprise edit to the test class in the same step.
- Run AUnit again. Failure means the message does not match. Error means the run threw. Fix the assembly or reject the edit. Do not update the expected XML to match a broken transform just so the bar turns green.
- Deploy and run in Studio only after that second run is green, and only through your normal Studio deploy. AUnit does not deploy the integration.
The AUnit 101 sample is also the place to see a test that ends in an error handler, because @AssertAfterCompletion can assert on props['error.count']. If your assembly is supposed to record a validation failure and continue, assert on that count. If it is supposed to stop, assert that the later step did not run, using @AtComponent to terminate or using an assertion that the later output is absent. Decide which behavior you want before the assistant “makes validation stricter.”
A small test worth writing first
This is the sample’s structure, with the names you would replace. It is the minimum that fails closed.
@AssemblyTest(project = "PayrollReconcile")
public class PayrollReconcileTest extends AssemblyTestCase {
@UnitTest(startComponent = "Reconcile")
public void testOneWorker() throws Exception {
setMessagePart(0, "test/one-worker.xml", "text/xml");
}
@AssertAfter(id = "Reconcile", step = "transform")
public void totalsMatch() throws Exception {
assertTrue(compare(
getTestResourceInputStream("test/one-worker-expected.xml"),
"text/xml",
(InputStream) getMediationContext().getMessage().getMessagePart(0, InputStream.class),
"text/xml",
Comparator.dom));
}
}PayrollReconcile, Reconcile, and transform have to be your project, component, and step. The expected file has to be the output you already trust. Run this until it is green. Then let an assistant edit the transform. Run it again.
@AssertBefore is how you lock the input. If the assistant “helpfully” rewrites the start of the assembly, a before-assertion on the original message fails immediately, which is what you want.
Failure modes
- The test is green because the assertion was deleted. Read the test diff. AUnit does not fail a test that no longer asserts.
- The test errors instead of failing. The step id in
@AssertAfterno longer exists, or the message is not XML the comparator can read. Restore the id or fix the transform. Do not catch the exception inside the test to force a pass. - The test calls Workday. You skipped
@AtComponentmock on the outbound step. A unit test that needs a tenant is not the test you can run before every edit. - You accepted an edit to the expected file and the assembly together. You no longer have a baseline. Revert the expected file from the commit that was green, and run again.
- You treated an Extend Validate as this gate. App Builder validation does not run AUnit. Studio runs AUnit. They are different tools and different projects.
Frequently asked questions
Does Developer Agent run AUnit?
Workday’s Developer Agent overview does not say it edits Studio assemblies or runs AUnit. Run AUnit in Studio yourself before you accept an assembly edit from any assistant.
What is the difference between a failure and an error?
A failed assertion aborts the run and is reported as a failure. An unexpected exception aborts the run and is reported as an error. Read which one Studio shows before you change the assembly again.
Do I need a test per processing chain?
You need a test for the chain an assistant is allowed to edit. The AUnit 101 sample has 8 chains and is a demonstration, not a quota. One @UnitTest with an @AssertAfter on the step you care about is enough to start. Add @AtComponent with mock on any step that would otherwise call out.
Where do I see a known-good run?
Open the AUnit 101 sample assembly in Studio and run it. Studio shows the results for those sample tests. Use that once so a red run on your project is familiar, then rely on your own expected files.