1

I am writing unit test to test some converters in my app which has three languages. The test results depends from the value of the language.

For example, if the language is "en", I should expect one output, and if the language is "fr", I should expect different output.

Is it OK inside my test method annotated with @Test to make three calls to one method that receives language as method parameter, or should I duplicate my code and create three different test methods, each for a specific language?

2
  • each method should (in best case) have (at least) a dedicated test. You are testing the method, not groups of methods. Commented Dec 22, 2015 at 12:21
  • Yes, one test is OK. Make sure you give it a name indicating what it tests, for example: testMethodXWithAllLanguages() Commented Dec 22, 2015 at 12:29

1 Answer 1

4

Having separate tests for each language would give you better test reports, but you don't need to necessarily duplicate the code, create private methods inside the Test class and reuse them.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.