Solved

Getting error when running ClassGenerator.exe from Test SDK 22.211.0034

  • 12 September 2023
  • 11 replies
  • 205 views

Userlevel 2
Badge

I’m trying to generate wrapper classes using ClassGenerator.exe and running it as a CLI tool with the config file.

I’m getting the following error as soon as executable starts:

C:\Users\abaranov\Documents\Work\_AcumaticaSoftware\TestSDK_22_211_0034_35\ClassGenerator>ClassGenerator.exe
Wrapper generation has started, please wait. It may take up to 5 minutes for the first wrapper to be successfully generated.
Process FAILED - so301000
System.Exception: Unable to get screen so301000 with url /CstDesigner/abaranov_PCBCustomizations/so301000.aspx ---> System.Exception: Exception of type System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.; StackTrace: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: This method cannot be called during the application's pre-start initialization phase.

Configuration file ClassGenerator.exe.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="SitePhysicalPath" value="C:\AcumaticaInstances\hemasource" />
    <add key="GenResultPath" value="C:\Users\abaranov\source\repos\gitlab-hemasource\TestSDK_22_211_0034_35\ClassGenerator\Out" />
    <add key="Username" value="abaranov" />
    <add key="Namespace" value="GeneratedWrappers.Acumatica" />
    <add key="ClearOutput" value="true" />
    <add key="FilenameFilter" value="SO301000" />
    <!--<add key="PagesList" value="list.txt"/>
    <add key="PagesParameters" value="ParamsPP.txt"/>
    <add key="GenericInquiryParameters" value="ParamsGI.txt"/>
    <add key="PagesListAttribute" value="exclude"/>
    <add key="PagesListAttribute" value="include"/>-->
  </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
  </startup>
</configuration>

icon

Best answer by AaronB 7 December 2023, 14:30

View original

11 replies

Userlevel 4
Badge +1

Hello Andrey,

 

I would ask if the page is accessible from the website. Its possible you need to restore the web.config of the website if the site is offline. Go to the website install folder and copy the contents of the backup web.config.d846d25d.txt into the web.config and reload the webpage.

 

It is recommended to do wrapper generation via code - and to use the following project as your base code template/file structure.

https://github.com/Acumatica/Test-SDK-Starter-Guide

Please note the GenerateWrappers() method in Test.cs for the example - The variable physicalSitePath must also be filled on line 17 as well. Line 29 and 30 also need to be correct for your website’s username & check that you are using the correct path in the projects launchsettings.json to the configured config.xml in the TestSDK_22_211_0034_35 folder you have.

 

You will also need to ensure you go to Manage Nuget Packages and add the “packages” folder from the above testSDK folder as a nuget source & import all the packages.

 

All this is found in the readme of the template project - it gives instructions on how to set up the project step by step, it takes about 5-15 minutes to configure the project and import any existing tests/extensions you have.

Userlevel 2
Badge

Hello Andrey,

 

I would ask if the page is accessible from the website. Its possible you need to restore the web.config of the website if the site is offline. Go to the website install folder and copy the contents of the backup web.config.d846d25d.txt into the web.config and reload the webpage.

 

It is recommended to do wrapper generation via code - and to use the following project as your base code template/file structure.

https://github.com/Acumatica/Test-SDK-Starter-Guide

Please note the GenerateWrappers() method in Test.cs for the example - The variable physicalSitePath must also be filled on line 17 as well. Line 29 and 30 also need to be correct for your website’s username & check that you are using the correct path in the projects launchsettings.json to the configured config.xml in the TestSDK_22_211_0034_35 folder you have.

 

You will also need to ensure you go to Manage Nuget Packages and add the “packages” folder from the above testSDK folder as a nuget source & import all the packages.

 

All this is found in the readme of the template project - it gives instructions on how to set up the project step by step, it takes about 5-15 minutes to configure the project and import any existing tests/extensions you have.

 

Hi Aaron,

Thank you for comments.

Yes, page is accessible from the website.

I tried running wrapper generation via code (actually used your project for that), and it fails with the same error on the line where wrapper is excuted:

WG.Run("SO301000"); // add all screens here you need to use in your test

 

Actually, I found that both CLI and “via code” work correctly on a clean vanilla site with sales demo data, but both fail when running against our customized instance.

 

Best regards,

Andrey

Userlevel 4
Badge +1

Hi @abaranovhs 

I see your error is “This method cannot be called during the application's pre-start initialization phase.” indicating the website was not fully online yet. 

 

  1. Try to load the website on your browser first to let the server wake the website up before running the test
  2. Make sure you run the GenerateWrapers() method after a PxLogin.LoginToDestinationSite(); command
  3. Check that the GenerateWrapers() method runs inside the Execute or BeforeExecute
Userlevel 2
Badge

Hi @abaranovhs 

I see your error is “This method cannot be called during the application's pre-start initialization phase.” indicating the website was not fully online yet. 

 

  1. Try to load the website on your browser first to let the server wake the website up before running the test
  2. Make sure you run the GenerateWrapers() method after a PxLogin.LoginToDestinationSite(); command
  3. Check that the GenerateWrapers() method runs inside the Execute or BeforeExecute

Hi Aaron,
Yes, I tried all 3, and also I found that both CLI and “via code” work correctly on a clean vanilla site with sales demo data, but both fail when running against our customized instance.

Userlevel 7
Badge

Hi @abaranovhs were you able to find a solution? Thank you!

Userlevel 2
Badge

Hi @abaranovhs were you able to find a solution? Thank you!

Hi Chris,

No, I wasn’t. So far my experience with Acumatica Test SDK was a complete failure, and I switched to looking for other options.

Thanks for asking, though

Userlevel 4
Badge +1

Hi @abaranovhs 

I have created a walkthrough video guide going through the process of setup so there is no ambiguity on the required config steps
 

 

Userlevel 2
Badge

Hi @abaranovhs 

I have created a walkthrough video guide going through the process of setup so there is no ambiguity on the required config steps
 

 

Hi Aaron,

I watched the video, but it did not help.

The problem is that wrappers are not generated, and exception is exactly the same as in the original post.

I am running your solution against my local Acumatica site that has all customizations already published in it, and WG.Run(“<custom screen>”) fails, no clues on why, exception as you can see is not informative at all.

Will be happy to jump on a call and work on this together

 

Best regards,

Andrey

Userlevel 4
Badge +1

Hi @abaranovhs 
If you are an ADN L2 subscriber you can create a ticket on the partner portal and we can organize a meeting to debug your issue together.

 

I still believe your website is corrupted in ways causing this issue. Please try to follow the guide from the very start including downloading and installing a new version of Acumatica and Acumatica Test SDK and using the recommended file paths.

If on a new website it still doesnt work - it means your customization project has some bad code inside of it relating to that CstDesigner/abaranov_PCBCustomizations/so301000.aspx file.

I bolded the parts i don't expect to see in the wrapper generation process.

Process FAILED - so301000
System.Exception: Unable to get screen so301000 with url /CstDesigner/abaranov_PCBCustomizations/so301000.aspx ---> System.Exception: Exception of type System.Reflection.TargetInvocationException

  1. The screen path is usually found in the pages folder of the website not CstDesigner
  1. The screen is usually SO301000 with Capital SO
  2. If you are working with the same PCB team that work with for certification, I can assure you the PCB package is working and would not produce this issue normally

 

 

Userlevel 2
Badge

@AaronB ,

With some dedicated time, and after meeting Acumatica QA Team at the Summit, I was able to make progress with TestSDK.

I still have issues generating all wrappers for all customized screens that we have, but I found a few workarounds:

  1. Removing all DLLs from Bin folder (while keeping customized ASPX pages in the Pages\ folder) and putting .cs files in to App_RuntimeCode\ folder to let Acumatica build all necessary logic behind the pages, in this case wrappers for custom pages are generated successfully
  2. Using wrappers generated by Acumatica for all standard screens, and adding extensions to them manually, relying heavily on DynamicControl<>() functionality

So now I am in a different realm - of writing automated tests using Acumatica TestSDK, and now I have many questions that I don’t find as clearly described in the documentation.

I hope you can provide me with some guidance on them.

Questions

Question #1 How can I continue running tests if one of them fails?

I am running them as following:

Test4 test4 = new Test4();
Test5 test5 = new Test5();
test4.Execute();
test5.Execute();

and in each test I wrap execution in the following way:

using (TestExecution.CreateTestCaseGroup("Test Case 1"))
{

using (TestExecution.CreateTestStepGroup("Test Step 1"))
{
// code of the step 1
}

using (TestExecution.CreateTestStepGroup("Test Step 2"))
{
// code of the step 2
}
}

as a statement to verify something I use something like:

VerifyContains("").Assert()

 

So, in case if test 4 has Assert() that fails, then the entire execution is stopped by exception, and test5 doesn’t run.

What is the best practice of organizing the code that uses Acumatica TestSDK so that all test cases could be run?

Question #2 What is the best way to review results of the tests?

Are there any built-in methods of integrating TestSDK results with QA Automation platforms (TestRail)?

QA Team said you have internally a portal, that TestSDK is submitting results to. Do you have a publicly available version of such portal, that I could use?

Userlevel 4
Badge +1

Hi Andrey,

1) You can specific commands that may fail into a try/catch & it will continue past the step if it fails without stopping the execution

2) No we do not support external QA automation software natively. Our automated testing portal is an internal tool unfortunately

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved