Hello
ja...@chromium.orgI would like to formally update the styleguide/java/java.md to call out some test style patterns that I find fairly common across the code base. I want our test code to be more homogenous, and I think documenting consensus will help us achieve this.
1. @Mock/@Captor should be preferred over inline creation of these objects.
2. Functions from commonly used test libraries, especially org.junit.Assert, org.mockito.Mockito, and org.mockito.ArgumentMatchers should be statically imported. These functions are very common in test code, and static imports help keep lines short, terse, and readable. There's often no ambiguity about where these functions are coming from, and since they are commonly statically imported in test files, this practice isn't surprising.
3. New test files should be in the same directory as the files under test.
Especailly, I find AI repeatedly creating inline Mock objects, and I am asking in code reviews many times per week to move them to member fields with @Mock annotations.
Thanks,
Sky