0

In order to assert multiple attributes of a call, I am planning to use auto-value.

But the documentation says:

  // You probably don't need to write assertions like these; just illustrating.
  assertTrue(Animal.create("dog", 4).equals(dog));
  assertFalse(Animal.create("cat", 4).equals(dog));
  assertFalse(Animal.create("dog", 2).equals(dog));

https://chromium.googlesource.com/external/github.com/google/auto/+/auto-value-1.6.2/value/userguide/index.md#usage

What are the better ways of asserting multiple attributs of dog?

Sandeep Jindal
  • 14,510
  • 18
  • 83
  • 121
  • I don't understand the question. Your linked page says directly above the code: »Note that in real life, you would write tests that actually do something interesting with the object, instead of only checking field values going in and out.« – knittl Jan 20 '23 at 14:12
  • Probably ... you just need to write assertions like the *other* ones in that section of the documentation. That's what it seems to be saying. Either way I think you need to just try it out. Create a testcase, run the autovalue generator and see what you get. And repeat until you 1) understand what it seems to be doing and 2) are happy with the results. – Stephen C Jan 20 '23 at 14:13
  • Why don't you simply write every test in isolation, to make sure you are testing each features. If you have to test many cases in one test, it is clear that you have an issue with your design. The `Single Responsibility Principle` is not apply in your design. – Harry Coder Jan 20 '23 at 16:23

0 Answers0