jeudi 8 septembre 2016

Unit testing, JUnit: multiple versions of tested app tested by one JUnit test

please let me explain and ask for help. Our app is as follows: [Frontend] <-restAPI-> [Backend] Backend supposed to be always at the latest version and can support multiple versions of the frontend, like Ver1, Ver2, etc. There could be minor changes in the restAPI protocol or even how the frontEnd reacts (more function or different behavior).

This test project tests correct communication, how the frontend behaves and backend for serving right data. We would like to have the same test project branch to be used for all supported versions, right now there are really only minor differences so our java test code have

if (version == "ver1") {
    ....
} else if (version == "ver2") {
    ....
}

Question is what is the most elegant way to split the versions ? Right now it works, but as version number will rise it would became a mess. I thought like to have a parent @Test method and decide which child test to run according to the version.

BasicTest.java
BasicVer1Test.java
BasicVer2Test.java

Question is if my idea is good, maybe somebody faced similar problem. Thanks.

Aucun commentaire:

Enregistrer un commentaire