I have over 3 years of experience in Java+Selenium WebDriver+Maven framework.

I have people using different annotations applied on functions. These annotations were not part of tool's inbuilt feature but custom made.

Question(s) is:

  1. How to create such annotations?
  2. Which annotations are must have or best practice to have in your automation f/w?

Framework: Java+Maven+WebDriver+[Junit/TestNg]

Note: I know that I am asking two questions. I know that I am asking a question #2 which subjective and suppose to close but I don't any other forum where my queries can be answered.

Being beginner need some guidance.

  • Please follow along the below article on annotation: java documentation on annotation. docs.oracle.com/javase/tutorial/java/annotations/declaring.html Dec 11 '18 at 3:53
  • OK and Which annotations do you think would boost the framework or best practices?
    – paul
    Dec 11 '18 at 3:56
  • Annotations don't boost your framework. Below are the major usage of annotation. Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings. Compile-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth. Runtime processing — Some annotations are available to be examined at runtime. Dec 11 '18 at 4:12

Annotations are the way how you mark up your code. They are used when you build your logic in a run-time (this mechanism is called Reflection).

So having annotations does not automatically make your code more effective. You should be quite experienced developer to power your code with annotations. Otherwise you will only do your code less understandable and more error-prone (since you won't have the change to catch your mistakes which you could catch on a compile time).

All this means that you probably misunderstand annotation concept since your question Which annotations are must have or best practice is almost the same as Which functions are must-have since you do not pick annotations from some pre-defined set. It is up to you how to define those annotations, which parts of code to mark-up with them and how to process all this in run-time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.