-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Betterize new unit testing framework #1297
Conversation
636ef33
to
bedb150
Compare
I think that is a good idea.
I think the current solution with the The format in the specification can easily be transformed to the unit test. What problem do you see by the token solution? |
Well, firstly, I simply couldn't appropriately feed the
The main downside that I see is that when transforming the specification into the unit test, commas need to be removed when added in the code. But personally I didn't find it to be much of a hassle when using a proper text editor. Plus, note that if one or more are included by mistake, this will produce a warning message, such as:
|
@matsduf What are your thoughts after my last reply? I would like to have a consensus and have this PR merged before doing more unit test in the new framework. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new data structures for describing the expected outcomes of each scenario.
Firstly, they are self-documenting: keys like mandatory
and forbidden
make it crystal clear to me that these are tags that must, or must not appear when running a test against a given zone.
Secondly, the syntax is flexible and there are no hidden surprises, because Perl’s syntax applies.
Thirdly, these structures can be extended by means of additional keys, to accommodate situations that require it.
I also like the idea of the testable
key, which documents scenarios for which we lack the means of testing automatically for the time being.
First I want to state that I am in favor of finding a format that makes it easy to create and maintain the unit test files, and where a unit module, such as the one that you have created, contains shared code.
If you set a package name in the file, the DATA data will be available as PACKAGE::DATA file handle.
I do not see the direct need of named keys. A small header or a pointer could solve the information need. A readable and compact format is more valuable.
The scenario name is in the zone name, so that is not needed. The zone name could be the key instead. That would make it shorter. The scenario name is not used for the unit tests.
Yes, that is really a good idea.
Well, I do not think that is important. A standardized header first and then specific data at the end works as well.
Yes, that could be good, but on the other hand, what we want for the test cases are really fixed format.
I still think the Then following would create a more compact format with fewer lines:
|
@matsduf @marc-vanderwal Following discussions here and elsewhere, I have made the suggested changes as well as adding some value checking of the new hash/array structure. See commit ef82b8a. Please re-review. |
- Create helper module 't/TestUtil.pm' - Create helper function 'TestUtil::perform_testcase_testing()' - Refactoring
Replace sub-structure from HASH to ARRAY Add some value checking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve this PR, but I would like to see the following improvements in documentation, which could be in a follow-up PR:
- In
TestUtil.pm
the fields of the%subtests
should be defined and described. Specifically, it is unclear what the "testable" field does. What happends when true and false, respectively? - In the "template" for the
t
file there should be a pointer toTestUtil.pm
for the definition of the%subtests
fields. - In the "template" for the
t
file there should be a link to the specification of the scenarios in queestions, i.e. https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/test-zones/DNSSEC-TP/dnssec16.md and https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/test-zones/Zone-TP/zone09.md, respectively, for thet
files in this PR.
Update documentation Add links to the test zone specifications
Good suggestions, I did indeed forget to update the documentation. I addressed your comments in commit e616dfe. Please re-review. |
Change the format of the test declarations inside t/Test-zone11.t so that it conforms to the format specified and agreed to in zonemaster#1297. This is unfortunately not a lossless conversion: the old format made it possible to specify extra checks such as “for zone all-different-spf.zone11.xa, the Z11_DIFFERENT_SPF_POLICIES_FOUND should be output 3 times”. Hopefully this can be brought back somehow later. Also, for some reason, the changes in the .t file required a new test run with ZONEMASTER_RECORD=1 set in the environment.
Change the format of the test declarations inside t/Test-zone11.t so that it conforms to the format specified and agreed to in zonemaster#1297. This is unfortunately not a lossless conversion: the old format made it possible to specify extra checks such as “for zone all-different-spf.zone11.xa, the Z11_DIFFERENT_SPF_POLICIES_FOUND should be output 3 times”. Hopefully this can be brought back somehow later. Also, for some reason, the changes in the .t file required a new test run with ZONEMASTER_RECORD=1 set in the environment.
Change the format of the test declarations inside t/Test-zone11.t so that it conforms to the format specified and agreed to in zonemaster#1297. This is unfortunately not a lossless conversion: the old format made it possible to specify extra checks such as “for zone all-different-spf.zone11.xa, the Z11_DIFFERENT_SPF_POLICIES_FOUND should be output 3 times”. Hopefully this can be brought back somehow later. Also, for some reason, the changes in the .t file required a new test run with ZONEMASTER_RECORD=1 set in the environment.
Purpose
This PR proposes an update to the new unit testing framework that is being put in place. It aims at improving the content of each test case unit test file (
t/Test-*.t
) by simplifying them. It does so with the following:__DATA__
token at the end of the file)###########
banners).With this PR, current test case unit test files (in the new framework) are reduced by about 30%.
I believe these changes are desirable to ease the migration process of other test case unit test files.
Context
Inspired from #1287
Changes
t/TestUtil.pm
TestUtil::perform_testcase_testing()
How to test this PR
Tests should pass.