Question

I am attempting to write my own integration tests project using SpecFlow for my custom module in Orchard CMS. I have created a new project which (currently) resides within the "src" directory (at same level as Orchard.Web).

Within that project I've created a "Bindings" folder and copied over 3 files from the original Orchard.Specs project: OrchardSiteFactory.cs, Settings.cs and WebAppHosting.cs

I've also created a new SpecFlow feature and done a simple test to check that a link appears in the admin menu for my custom module.

In WebAppHosting.cs I changed the value of _orchardTemp to reflect the name of the folder that my project is in, and in OrchardSiteFactory.cs I added my module name (along with any modules it relies on preceding it) to the list of Module extensions in the TableData parameter of webApp.GivenIHaveACleanSiteWith() method call in the GivenIHaveInstalledOrchard method.

This runs the site, installs the modules and copies all the necessary files from my custom module to the temp WebApp folder in Users{USER}\AppData\Local\Temp{FolderName}... in the same way that it does for all the other Orchard modules. However it does NOT activate / run the migrations code for my module.

By putting a breakpoint in the test code to stop it deleting the temp web app folder, I'm able to connect to the SQL Compact Db and have a look at the tables and data created, and there's no sign of my custom module at all.

I have searched and searched both online and in the Orchard code for a clue as to how to get the module to activate, as it obviously activates other modules (such as the Blogs module) but I'm drawing a blank. I have tried various combinations of the ExtensionDeploymentOptions and DynamicCompilationOption within WebAppHosting.cs with no joy.

My test scenario is simple:

Scenario: In the admin (menu) there is a link to the custom module
Given I have installed Orchard
When I go to "admin"
Then I should see "<a[^>]*href="/Admin/MyCustomModule"[^>]*>My Custom Module</a>" 

And it runs completely, only failing on the string comparison when it fails to find that link in the page (viewing the actual string in the HTML viewer shows the dashboard as you would expect, so everything else is working fine.

I'm off to investigate whether the recipes have any effect / can be tweaked within the test project. If anyone has any clue about how to get this to work I'd be really grateful

Cheers

ETA: The problem is the same as asked here on the Orchard forums, but there has been no reply to it : http://orchard.codeplex.com/discussions/259028

Was it helpful?

Solution

The solution was annoyingly simple in the end, I had forgotten the 2nd line

Scenario: In the admin (menu) there is a link to the custom module
Given I have installed Orchard
And I have enabled "My.Custom.Module"
When I go to "admin"
Then I should see "<a[^>]*href="/Admin/MyCustomModule"[^>]*>My Custom Module</a>"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top