mono / Embeddinator-4000

Tools to turn .NET libraries into native libraries that can be consumed on Android, iOS, Mac, Linux and other platforms.
MIT License
758 stars 95 forks source link

[objc] Value of unit testing objcgenerator-helpers.cs's GetSignatures and by extension NameGenerator? #313

Open VincentDondain opened 7 years ago

VincentDondain commented 7 years ago

I would like someone to enlighten me on the benefits / non benefits of unit testing GetSignatures and NameGenerator.

I know that the current way to test the generated code is to add a bunch of managed code that's supposed to cover all the corner cases and assert it works in objective-c using XCTest.

Meaning that the simple way the objective-c code compiles is fine.

However having extra tests in objcgen would IMHO bring the following advantages:

  1. Help debugging the objective-c generator. Maybe there's a way to debug that code other than doing Debug Test in the Unit Test pad with generator.sln open but I don't know it.
  2. Enforce formatting rules:
  3. Verify our NameGenerator logic:

Does that make sense? Is there even more value in testing this?

spouliot commented 7 years ago

Value? yes, it's not a boolean so there's always value :-)

This is not a case where tons of tests are likely to give tons more value. OTOH it's cheap to test and what's not tested generally does not work (for very long). So having a few tests covering the rules and corner cases seems a very good idea. You'll be quickly hit by the law of diminishing returns if you try to add more.

  1. You can debug the generator using the generator.sln, just give arguments to the objcgen project.

  2. Yes, but it's mostly for regressions (since you'll be supplying the input);

  3. Yes, it better be tested (again that will be against known values);

Now if the question was not about unit testing then my answer would likely be different, e.g. writing an ObjC parser to ensure we generated good code against any assembly input.