Jump to content
santiago

Dynamic Test creation possible?

Recommended Posts

Hello,

In DUnit we make heavy use of dynamic Tests.

 

For example, we have a test that loads a file from disk and performs some actions.

All of the files are kept in a directory. The TestSuite is built at runtime by searching for all relevant files.

For each file a Test is displayed in the Test Runner.

This is very handy when you want to test/debug just one specific file.

The alternative would be to have a single Test, such as TestAllFilesOfTypeXx...
But then it is not straightforward at all to troubleshoot a specific case.

 

DUnit_dynamic_tests.png

Share this post


Link to post

Yes but the real question is: why do you want to switch to DUnitX when you have working DUnit tests already?

  • Like 1

Share this post


Link to post

@Stefan Glienke

These are the main pain points with DUnit:

 

  1. Viewer has no filter functionality. When you have hundreds of tests, you have to scroll until you find the test you would like to execute.
  2. Viewer is not DPI aware. Seems to be no longer mantained.
  3. Lack of test categories.
  4. We would like to be able to specify which test categories to run. Normally you don't want to run all test while developing.

DUnitX seems to already have most features. Its open source, so I will take a look at how involved it would be to extend the viewer to show the tests grouped by category.

Could you please give me a hint on how to dynamically create a Test in DUnitX? It is sufficient if you mention which class(es) I should look at. That would be a great headstart. Once I have that figured out I can look into the viewer issue.

 

Thank you!!

  • Like 1

Share this post


Link to post

Hi @santiago,
did you ever get this working in DUnitX?

 

Would you mind sharing some of your DUnit(X) code,
I have a similar situation where a dynamic test for each subfolder would be better,
compared to 1 test: TestAllSubFoldersOf

Share this post


Link to post

Hello @Stompie,

 

unfortunately I have not been able to look further into this.

 

Let me know if you get that to work.

Eventually, at some point in time I will have to pick this up.

Share this post


Link to post
Posted (edited)

You can do dynamic test creation in DUnitX by creating a TestCaseProvider

 

https://github.com/VSoftTechnologies/DUnitX/blob/master/Examples/ProviderExample.pas

 

https://github.com/VSoftTechnologies/DUnitX/blob/master/TestCaseProvider.md

 

I just pushed a small change that makes it easier to create unique test case names. 

 

Note - this won't resolve the debugging one case at a time issue though, unless you modify how your TestCaseProvider somehow.   

Edited by Vincent Parrett
added note
  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×