dimanche 11 juin 2017

How to set a value of a variable during a test?

Suppose I have a code in Java (or any other language) that I want to test. Let's say that I want to test how the code behaves when variable 'myVar' holds an integer value of 10 at a certain line.

One option will be to assign the value 10 to variable 'myVar' at this line. This will work fine, but it will make the code dirty. If I want to test another scenario, I'll have to fix this line. What will happen if I have a huge number of scenarios ?

I was wondering whether there is an option to hold an external file/configuration that will be loaded whenever I want to test this specific scenario without modifying the code?

Aucun commentaire:

Enregistrer un commentaire