TestFactory: Passing individual *args/**kwargs/ subcase identifier to run_test has changed/ stopped working in 1.6.0
See original GitHub issueUsing TestFactory, I am facing difficulties in providing test-individual arguments to run_test() in cocotb==1.6.0.
I will elaborate on an example using the test-inidividual subcase
string:
- Prior usage ( with cocotb <= 1.5.2):
1.1 Assume a run_test, which gets a per-test individual string e.g. subcase
as an argument.
[...]
@cocotb.test(timeout_time=200000, timeout_unit="us")
def run_test(dut, subcase=None):
if not subcase:
print("ERROR: Subcase is none!")
[...]
1.2 Assume two different example test factories, which could provide the subcase
string with cocotb <=1.5.2:
1.2.1 First example TestFactory
factory = TestFactory(run_test)
factory.add_option("subcase", longListOfSubcases)
factory.generate_tests()
1.2.2 Second example TestFactory
factory = TestFactory(run_test)
for case in longListOfSubcases:
setattr(mod, arbitraryVaryingName, _create_test(run_test, arbitraryVaryingName, "nodoc", mod, case))
- Current problem: I failed when trying different approaches for providing test-inidividual arguments to run_test(). Either with implicit arguments like substring or explicit arguments it did not work for me. I am not sure, whether it is a bug, or me using the software wrongly.
Suggestion: Please verify how to provide test-inidividual arguments in cocotb==1.6.0. Thank you.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Error "TestEngine with ID 'junit-vintage' failed to discover tests ...
I found the error. The dependency on spring-boot-starter-test brings a dependency on junit-vintage-engine . The latter must be excluded:
Read more >Guide to Dynamic Tests in Junit 5 - Baeldung
A DynamicTest is a test generated during runtime. These tests are generated by a factory method annotated with the @TestFactory annotation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Coming across this by chance. Isn’t this issue due to the fact that using the
@cocotb.test()
registers the function as a test on its own, thus running it outside the test factory with, obviously,None
as a parameter (perhaps before starting the tests generated by the test factory) ?On a very side note, be careful when using
not stuff
to test ifstuff
isNone
. In your example, if you have an empty subcase, it will be treated as a “None”. You might prefer usingstuff is None
instead.Has your question been resolved? If so please close this issue. If it has not been resolved, you may need to provide more information. If no more activity on this issue occurs in 7 days, it will be closed.