Home QA Testing Test a simple java program with concordion

Test a simple java program with concordion

by support@1lyqa.com
test java program

I wanted to try from scratch a small java program that I would really make “Test Driven Develop”, starting with an automated “nice” test tool (Concordion). So after a few hoops and difficulties, here is how I set it up. I assume you have a working version of Intellij running. I am using a Mac.

The program I want to test is a Western numbers to Latin numbers converter. For example 18 should become XVIII.

  1. Start a gradle project in intellij
  2. in the build.gradle I put the following lines : as explained on the following Concordion page: https://concordion.org/integrations/java/markdown/#gradle

3. Reload the project in Intellij, so that the dependencies are taken into account. This can be done in the “Gradle View” : View >> Tool Windows >> Gradle

Now you are ready to launch Concordion. You will need to create 2 files : one Fixture : “LatinNumbersFixture.java” and one Markdown : “LatinNumbers.md”

4. Create the LatinNumbersFixture.java

package latin;

import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;
import translators.Latin;

public class LatinNumbersFixture {
public String getLatinNumberTest(int westernNumber){
String result = Latin.getLatin(westernNumber);
return result;


5. Create the LatinNumbers.md

# Conversion Tool Latin / Western

### Western → Latin

### [Examples](- "Western to Latin")

[convertToLatin][][Western][western] | [Latin Equivalent][latinResult] |
12 | XII |
18 | XVIII |
99 | LXXXXIX |
1300 | MCCC |

[western]: - "#western"
[convertToLatin]: - "#result = getLatinNumberTest(#western)"
[latinResult]: - "?=#result"

Ok now we have a test ready to be launched.

6. I found out that I needed to also set this on Intellij to be able to run the tests : in Intellij Preferences, “Run Tests using “Intellij IDEA” instead of default “Gradle”)

7. Create the java class Latin containing the static method getLatin(Integer x) that I use in my test:

8. Run the Concordion Test using the LatinNumbersFixture.java, and display the html results page :

there we go …. all good !

Hope you liked the reading.

Original Source

Related Articles