简体   繁体   English

测试方法内部调用多种方法

[英]Multiple methods calls inside test method

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. 测试结果取决于语言的值,例如,如果语言为“ en”,则我期望一个输出,如果语言为“ fr”,则我期望为不同的输出。 Is it ok inside my test method annotated with @Test to make three calls to one method that receives language as method parameter, or i should duplicate my code and create three different test methods, each for a specific language ? 在用@Test注释的测试方法中,可以对一个接收语言作为方法参数的方法进行三个调用,还是可以复制我的代码并创建三个不同的测试方法,分别针对一种特定的语言?

对每种语言进行单独的测试将为您提供更好的测试报告,但是您不必重复代码,在Test类内部创建私有方法并重用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM