I'm attempting to write some annotations to help associatate test case methods with various metadata. My annotations so far include BugFix, UseCase, and Requirement. My end goal is to write an annotations processor to display which test cases are associated with individual bug fixes, use cases, and requirements.
When I was just implementing this for my own project, I created enums specific for my project for each test association category. For example, I had ProjectUseCase enums, which I could pass as the value to the UseCase annotation on my test methods. This made it easy to add additional use cases or modify use cases in a single place.
Now, I'd like to make this code available for other developers at my work. Of course, they will be working on other projects, with different use cases, requirements, and bug fixes.
Here are the problems I'm running into:
- Enum cannot be extended, so I cannot have a base UseCase enum which others can extend for their own projects.
- Values for annotation properties have to be constants. This prevents me from using an interface marker (TestAssociation) on my enums, and using the TestAssociation interface for the values of my annotation. Also, this prevents me from using String values in my annotation, and passing in the enum name when I use the annotation, such as: @UseCase(ProjectUseCase.GENERAL.name()).
From what I can tell, this leaves me with just using raw Strings for the values, which deprives me of type safety and the ability to quickly refactor. Using classes of constant Strings in place of the enums seems to be the best way to handle this, as every developer can use their own.
The only other thing I can think of is to reference an Enum class (or a class of constant Strings), and not include the class in the jar, leaving it for the users to implement.
Any suggestions or workarounds?
I'd also like to know if there are any projects out there already providing similar functionality.