Setup:
<java.version>17</java.version>
<spring-boot.version>2.7.0</spring-boot.version>
<junit-jupiter-engine.version>5.8.2</junit-jupiter-engine.version>
<mockito-junit-jupiter.version>4.6.1</mockito-junit-jupiter.version>
<archunit.version>1.0.0-rc1</archunit.version>
In my recent Java 17-Project Arch Unit Tests are used.
It works fine so far and I'd like to extend the tests by blacklisting specific variable names.
Target: The question is not about "does it makes sense" - it is about "how to do it".
Sample Examples to get into my mood:
a) Blacklisting an Uuid.class to be named 'uuid'.
- Developers therefore have to use the allowed name 'id' or think of a more specific name regarding their purpose.
Sample Class:
import java.io.Serializable;
import java.util.UUID;
public record myClassRecordClass(
UUID id,
UUID uuid, <-- forbidden
UUID pupilId,
UUID teacherId,
String className
) implements Serializable {}
b) Blacklisting an 'until now used term' within a business case, as it has to be renamed.
- Falling back into the 'old habit/naming convention' shall be prohibited.
Nov. 2022: As far as I know classes, fields and members can be checked via ArchUnit, but not variable names.
In case the following PR might cover the issue ... https://github.com/TNG/ArchUnit/issues/768 ... somewhen in the future.
Nevertheless, did I miss a better solution? Is there any other way to tackle the issue?
Best wishes :)