Skip to content

Conventions and good practices

Alberto Martín López edited this page Jun 2, 2020 · 3 revisions

Table of contents

  1. Add new parameters to the RESTest configuration file
  2. Write unit test cases for every new functionality
  3. Document your code responsibly
  4. Use SonarLint to avoid bugs, vulnerabilities and bad smells

Add new parameters to the RESTest configuration file

Whenever you develop a new functionality that requires some parameter to be configured by the user, include that parameter in the RESTest configuration file.

To add a new parameter, you must include a new static field that will be set in the setEvaluationParameters(String evalPropertiesFilePath) method of the IterativeExample class. You must use the readExperimentProperty(String evalPropertiesFilePath, String parameterName) to obtain the value of the parameter from the properties file. For example, here's how RESTest gets the value of the oaispecpath parameter:

OAISpecPath = readExperimentProperty(evalPropertiesFilePath, "oaispecpath");

Write unit test cases for every new functionality

These tests should be placed under src/test/java folder. Every test class must have the same package name as the the Java class you are testing, and the same class name with the Test suffix.

Document your code responsibly

  • Clarify the purpose of the methods/classes you implement.
  • Create structure and readable code that does not require many inline comments.
  • Use Javadoc for hard-to-understand or important methods/classes:
/**
 * Description of your method.
 * 
 * @param demoParam Description of the parameter
 * @return What the method returns
 */
public String demoMethod(Integer demoParam) {...}

Use SonarLint to avoid bugs, vulnerabilities and bad smells

RESTest uses SonarCloud to evaluate the quality and the security of the code. If you want to check the quality of your code before actually committing it, we recommend you to use SonarLint. It is an IDE extension which evaluates your code quality and security in real time, adding warnings in the flaws found. You can use it in Eclipse, IntelliJ IDEA, Visual Studio and VS Code.