Instance root folder

Hallo,

Recently we have started developing a gui to run OpenTap test plans. We use Visual studio.

We have noticed that plans requiring a plugin loaded only work when an entire environment is copied into the debug/release folder. With this we are able to initialize an instance and complete a testrun.

(With an environment we mean a directory containing: Dependencies, Packages, Settings, tap.exe, etc…)

We are wondering if it’s possible to pass a path into the instance with the environments location, instead of requiring copying over all the files.

Thanks in advance,
Marc

Hi @marc_vd_klooster,

What you are doing is not a supported approach and it’s not documented, so you are going to have to do some debugging to get this to work.

The simplest is to just deploy the opentap installation into your bin folder (using the OpenTAP nuget package), but it is not impossible to structure things a bit differently.-

Here are some APIs you can consider when taking this approach:

  • PluginManager.DirectoriesToSearch - Adds additional directories to search for plugins
  • ComponentSettings.SettingsRoot - Control where settings are stored.
  • SessionLogs.Initialize - Control where the sessionlog is located via argument.

From what you write it sounds like you need to add something to PluginManager.DirectoriesToSearch and then call PluginManager.Search().

Hallo @rolf_madsen,

Thank you for your reply.
The sessionLogs we already had working in our program.

The Component settings are now being loaded and show up in de debug information.

We do struggle a bit with the plugins. We are able to add the directory with the DirectoriesToSearch function, which is followed by PluginManager.Search(). In the session log is visable that the pluginManager is able to find all plugins in our directory.
However, when loading and running a test plan, the Serializer shows an error in the session log stating that the ‘Package ‘< Name of plugin >’ is required to load, but it is not installed.’

I can see that AssemblyData is able to load for example the basic steps correctly.

Are we missing a function/action that needs to be performed to load/install after adding a directory?

Thanks in advance,
Marc

Got it. In OpenTap.Package there is a class called Installation, which manages information about the current installation (Installation.Current). That class look for installed packages and makes it possible to look up installed packages.

By default it assumes that the packages are installed inside a “Packages” folder in the same folder as the OpenTAP.dll file.

You could try to set OpenTap.Package.Installation.Current.Directory to your “environment” folder.

I have not tried this myself and it’s not something we actively support, but if there is no cacheinvalidation issue, it should work. (You could try calling Installation.Current.Invalidate() after setting directory in case of problems)

Hallo,

So far I have not been able to find/access “OpenTap.Package”. Thus I have not yet managed to try out the suggestions.

However, I did do another search through the examples provided by the SDK. Here I found the “BuildTestPlan.Api” in which there is a comment about what we are attempting.

As suggested before, it states to add: “PluginManager.DirectoriesToSearch.Add(@“C:\SomeOtherDirectory”);”. But there is no further requirements/actions to handle/perform.

I have taken the lines relevant to running a test plan to our program to test, but it lead to the same result as before.

Apperently I was missing a reference to OpenTap.Package . So that problem is solved.

I noticed that " OpenTap.Package.Installation.Current.Directory" is read-only. I’m able to make a new installation with the path of our “environment” succesfully. It shows all the expected plugins in the debug information.

As of now I have not much more information. But wanted this to share already before the end of the day.

Oh, actually you should be able to just add <OpenTapPackageReference Include="OpenTAP"/> To your csproj and that should add the reference to openTap.Package as well. if that does not work you can add a reference directly to the DLL in your output folder.

So far I’m not much further.

I am able to make a new installation with the “environment” root. it looks like it loads all plugins according to the debug info.

How can I use this to run a test plan?

I am a bit of a loss what next step/idea would be to try.

(as a side note: We are currently planning a different method for our initial program release. Here we plan to place out program inside the “environment” directory. As this mimics the current development setup. Which gives me more time to figure out the discussed method.)

Hi @marc_vd_klooster,

Sorry, you are right the Directory is not configurable. As I said, the path you are taking is not a supported use case.

As a last effort, maybe you could try setting the environment variable OPENTAP_INIT_DIRECTORY? That value will be read into the default installation if it exists.