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
Service Provider object is becoming null while running the script through commandline #121
Comments
Can you give us any more information? such as a demo? |
Sure, I will create a sample project, and share the details. |
@pengweiqhca, I have created a demo project, and in which the issue reproducing. Please go through the below demo project **Issue: ** While executing the test case through Comman Prompt, it is throwing System.NullReferenceException at ServiceLocator.cs:line 35 If we execute same test case through Visual studio, it is executing successfully. The issue is only with CommandPrompt execution. Note: For more details of execution, you can find the log details of execution in the TestExecutionLogs file under the bin\Debug\net6.0 folder |
Please use [MethodData], more see [MemberData] how to inject? |
@pengweiqhca , seeing below error after replacing the [MemberData] attribute with [MethodData] attribute (ex: [MethodData(nameof(TestData.GetLocationObject))]) Error message after running the test case: |
@pengweiqhca ,One observation, through command prompt execution, I assumed that - Startup file is not being called first. |
@pengweiqhca , Thank you for providing the fix details. It was executing successfully through Command Line and Visual Studio without any issues. |
In Startup.cs file, created an object for ServiceProvider as below
services.AddSingleton<IRestLibrary, RestLibrary>();
IServiceProvider serviceProvider;
serviceProvider = services.BuildServiceProvider();
During, any of other methods execution in that same Project, trying to get the data of serviceProvider. But that serviceProvider's data is showing as null.
The issue is only happening through the commandline execution. If we try to execute the same scenario through Visual Studio, it is working fine without any issues.
The text was updated successfully, but these errors were encountered: