-
-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I make quite heavy use of NetDNS2 in my application, especially to get a lot more insight and control into DNS lookups. It's a great library if you want to control which nameservers to send your query, and truly disect the exact DNS response.
To test my implementation code, I make use of Mockery to mock the Resolver, as well as the Response packet, so I know my code makes the right decision based on the information returned by the DNS query.
This worked fine with the V1 client. But this approach doesn't work at all with the V2 client, because:
- Mockery works by dynamically extending the parent class with a mock class, so it can intercept calls while still passing type checks. But with the V2 client, almost every class is designated as
final, which prevents this trick from working. - An alternative to this would be to build a mock based on an abstract or an interface, but the client contains no abstract classes or interfaces.
- Mockery supports proxy objects, but this breaks all type checks. And I need input types for the dependency injection to work correctly.
- Many data representation objects take only
dataas their input argument, with no definition as to what thisdatais supposed to look like, making it hard to construct these data objects manually for testing.
Based on this, my questions are:
- What is the recommended way to test code that uses this library? Was this use case even considered? And no, just testing against actual DNS servers is not feasible for me.
- Would you be willing to add interfaces to the library, at least for any class that's final?
- Or would you be open to dropping the
finaldesignation from most classes at all?
For these last two, I'd be willing to put in the work, but I would like to know beforehand what you'd be willing to accept.
Metadata
Metadata
Assignees
Labels
No labels