Skip to content
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

There's no way to configure test hierarchy at runtime #33

Closed
RomanYankovsky opened this issue Jan 11, 2014 · 6 comments
Closed

There's no way to configure test hierarchy at runtime #33

RomanYankovsky opened this issue Jan 11, 2014 · 6 comments

Comments

@RomanYankovsky
Copy link

TDUnitXTestRunner uses unit names to create test hierarchy and there's no way to change this behavior (please correct me if I'm wrong). Do you plan to add more flexibility to this class?

For instance, DUnit provides TTestSuite class for creating test hierarchy. I don't propose adding some sort of TTestSuite to DUnitX, but I believe DUnitX misses this feature.

@vincentparrett
Copy link
Member

I will take a look at this.. at the moment the fixtures are all generated internally at runtime, I'll see if we can add some sort of api to allow you to generate them.

@RomanYankovsky
Copy link
Author

Actually, I can take on this task.

@vincentparrett
Copy link
Member

I've made a start already, should have it working in the next day or so.

@RomanYankovsky
Copy link
Author

@vincentparrett thank you!

@vincentparrett
Copy link
Member

this is where I'm heading

IFixtureProviderContext = interface
['{933F8442-77F1-4574-BB5E-2F3D0B8E6E6F}']
function CreateFixture(const AFixtureClass : TClass; const AName : string) : ITestFixture;
end;

IFixtureProvider = interface
['{48D58C88-1236-4B96-9D5F-5DD81DB71504}']
procedure Execute(const context : IFixtureProviderContext);
end;

IPluginLoadContext = interface
['{0A60FE65-C3E3-4E98-9686-8BB6A793810B}']
procedure RegisterFixtureProvider(const provider : IFixtureProvider);
//procedure RegisterSomeOtherFeature(const provider : ISomeOtherFeature);
end;

IPlugin = interface
['{C706DD67-58D0-4B66-92A6-6FBE2AF065A4}']
procedure GetPluginFeatures(const context : IPluginLoadContext);
end;

So you would need to create a class that implements IPlugin, and another that implements IFixtureProvider, which you register when your plugin class's GetPluginFeatures method is called. The IFixtureProviderContext interface has methods for createing a ITestFixture, which has methods for adding child fixtures and tests. I'm going to refactor the internals of DUnitX to use this architecture as well, should clean up the fixture class a lot (I'm not all that happy with it, does too much in the constructor).

@vincentparrett
Copy link
Member

I have implemented the needed functionality in DUnitX and submitted a pull request for DelphiSpec. It's not perfect, DUnitX expects the test methods to be on the same class as a fixture, so I had to create a fixture per scenario. If you can see a better way to do it, I'm open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants