JUnit - 如何测试具有不同值的方法? [英] JUnit - How to test a method with different values?

查看:119
本文介绍了JUnit - 如何测试具有不同值的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法,希望用不同的值测试它。我的问题是:如何编写一个JUnit测试,用不同的值测试相同的方法?

I have a method and wish to test it with different values. My question is: how can I write a JUnit test that would test the same method with different values?

推荐答案

你可以拿一个请参阅示例中的参数化测试。

You can take a look at parametrized tests like in example.

您还可以使用理论在很多情况下更方便。

You can also use theories which is more convenient in a lot of cases.

这篇关于JUnit - 如何测试具有不同值的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆