I want to use a custome GUI to Run Testplans, that I make in the Editor. I have a custom Avalonia GUI. I can run example Testplans, and even Testplans, containing my own plugins that I have written in C#, from this GUI. I also can run any Testplan including Python ones, in the Community Editor, which I’m using to make the Testplans. But for some reason I can’t run TestPlans containing Python TestSteps, throught the .Net API. I get an error like this:
“XML Line 4: Unable to locate type ‘PythonExamples.BasicFunctionality.BasicFunctionality’. Are you missing a plugin?\nXML Line 4: Unable to deserialize test step.\nXML Line 19: Unable to locate type ‘PythonExamples.BasicFunctionality.BasicFunctionality’. Are you missing a plugin?\nXML Line 19: Unable to deserialize test step.”
So it looks like the .NET API can’t recognize Python-based plugins, even though they work perfectly in the Editor. Is there some setting that I’m missing? Or is it simply not supported to run Python TestSteps through the .NET API?
A bit more about my goal, and my setup:
I want to make a multiplatform GUI (Win/Linux) for testing. I have made a few teststeps, duts, and instruments already, both in C# and Python. Every python package I need is globaly installed on the PC, not in a VE as well as Python. Using OpenTap 9.29. with the new Community Editor.
Smaller extra question:
When loading a Testplan using the .NET API, I also get issues if the Testplan XML contains <Package.Dependencies> section like this:
It’s automaticly generating if I make TestPlans throught the Editor. If I comment it out, everything loads fine — but it feels unnecessary. Is there a recommended way to handle package dependencies in custom runners?
Thanks, for the fast reply. I have the python plugin installed, thought its 3.1. Where do you suggest putting this PluginManager.Initialize(); ? My code looks very similar to the example code:
Load package locations
Set log file
Add an absolute testplan path
Add settings path
Add result listeners
OpenTap.PluginManager.SearchAsync();
Add settings profile, dut and instruments
l Load the testplan
Execute
…
I always get the error at the Load step(8). I tried it before the 1st step and before the 8th step. Neither worked.
I also checked with PluginManager.GetAllPlugins(): It couldnt list my python packages, nor the example package, but could list the Opentap.python package itself, and my C# packages, or other Opentap packages.
I just saw that pythonnet is being used for the Opentap.python project. Could it be that I also have to init that?
Ok, since you already use the plugin manager, it should be initialized properly.
Maybe you can try loading your custom GUI as a command line action. If you implement the ICliAction and add a appropriate display name, then you can get the tap executable to launch the UI from the command line. e.g “> tap my-ui”, if that works its because OpenTAP got properly initialized.
Otherwise, did you see any warnings or errors during startup? Did the python plugin say which version of python it found?
@rolf_madsen It looks like it can only detect plugins that contain dll files. Those plugins that contain only .py files remain undetected. Any idea what should be done?
@abel1, can you confirm that everything works when you run Editor.exe?
Is your working directory the same location as Editor.exe? the Package directory must be located in the folder the application sees as the working directory.
@rolf_madsen Everything works in Editor.exe. I tried to put the package both in the global opentap installation and in the C# project debug folder. The C# project is not located inside an opentap installation, nor it is in a virtual environment.
Could you tell me the steps for running a testplan containing steps form pythonexamples throught the API? Maybe I’m missing something.
So I managed to run my test successfully from a small C# class that implements ICliAction. However, when I run the exact same code from a standalone C# console application, either from a published executable or directly in visual studio, it doesnt seems to be working.
I haven’t tested that yet, but I guess thats also means if I start my custom GUI from the OpenTAP Cli it would also work. And I think it’s not that much of a problem for me to run the app from CLI since, the GUI’s primary target is Linux.
Does this mean that OpenTAP cannot be properly initialized from a plain C# application when I want to execute Python-based test steps? Is this behavior related to the fact that OpenTap.Python is a separate package and not part of the OpenTAP core? If so, what is the reason OpenTap.Python is not included in the core, and what is the recommended way to initialize OpenTAP correctly from C# to run Python steps?
P.S.: Merry Christmas and Happy New Year to everyone!
I’ve made progress and can now successfully load and execute Python-based testplans.
However, I’m running into an issue where Python DUTs and Python Instruments are not discovered, even though, the testplan XML is found and parsed correctly , Python teststeps from the same plugin are discovered, and Non-Python instruments defined in the same testplan XML are discovered correctly. (All Python DUTs, Instruments, and TestSteps come from the same Python plugin.) I’m trying to get the duts and instruments from Bench Settings.
When loading the testplan, I get the following error:
Exception: XML Line 6: Missing ‘PyInstrument’ used by ‘Basic Functionality.Instrument’
XML Line 7: Missing ‘PyDUT’ used by ‘Basic Functionality.Dut’
XML Line 21: Missing ‘PyInstrument’ used by ‘Basic Functionality (2).Instrument’
XML Line 22: Missing ‘PyDUT’ used by ‘Basic Functionality (2).Dut’
XML Line 36: Missing ‘PyInstrument’ used by ‘Basic Functionality (1).Instrument’
XML Line 37: Missing ‘PyDUT’ used by ‘Basic Functionality (1).Dut’
What’s confusing is that, the Python teststeps from this plugin are visible and usable and the XML clearly references the correct type names, only the Python DUTs and Instruments are reported as missing.
This only happens when running OpenTAP via the API. When running the same testplan via the CLI, everything works, although running the whole tester app from CLI gives errors that are not connected to OpenTap. Thought not for the errors, but it would be ideal not to run the tester app from CLI.
Is there a separate discovery or registration step required for Python DUTs/Instruments? Are Python Instruments/DUTs loaded later than teststeps? Is there something specific that must be initialized when embedding OpenTAP without CLI?
Hi @matev03, Python DUTs and Instruments are loaded whenever something asks for it. In this case, the serializer module is detecting that a DUT or Instrument is needed and then checks instrument settings, but does not find it.
This requires that instrument /DUT XML settings can be read at the time the test plan is deserialized.
Are you setting the settings profile or settings directory at some time during startup?