It seams that it is unreasonable to put more than one test methods in a test class, since it does not make sense to add two sets of static data points in one class. Is it a best practice to have only one test method in a test class?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. There are several methods to have multiple Theories in a single test class.
@DataPointsof different types@DataPointsof the same type (for example one being valid cases and one invalid) and useassumeThatto limit a@Theoryto only use values from one set.@Tests as well as@Theorys in the same test classEnclosedrunner to run multiple inner classes each with their own set of exclusive@DataPointsMuch of this depends of course on the complexity of the class under test. But I usually mix
@Theorywith@Testand in several cases had multiple different@DataPoints. A common example of this is a class with multiple setters each taking a different type.