[英]How to retrieve data from appsettings.json, when execute Nunit test in bitbucket pipeline
I have a test automation framework for API testing with below structure:我有一个用于 API 测试的测试自动化框架,结构如下:
In appsettings.json file I store any data for tests:在 appsettings.json 文件中,我存储了任何测试数据:
I retrieve data from appsettings.json with help of ConfigManager class:我在 ConfigManager class 的帮助下从 appsettings.json 检索数据:
When I execute my test on my local machine, everything is OK, but when I try to execute it in bitbucket pipeline, I get NullReferenceException (when try to use variable form ConfigManager (eg BaseUrl)).当我在本地机器上执行测试时,一切正常,但是当我尝试在 bitbucket 管道中执行它时,我得到 NullReferenceException(当尝试使用变量形式的 ConfigManager(例如 BaseUrl)时)。 Here is my.yaml file:
这是我的.yaml 文件:
If required data is hardcoded:如果需要的数据是硬编码的:
test is passed in pipeline run.
测试在管道运行中通过。 Therefore, I believe that the problem is precisely in the correctness of data extraction from the json file.
因此,我认为问题恰恰在于从 json 文件中提取数据的正确性。
My question: is there anything wrong in my code?我的问题:我的代码有什么问题吗? Should I add anything in yaml file to be able to get data from appsettings.json?
我是否应该在 yaml 文件中添加任何内容才能从 appsettings.json 获取数据? Any help would be valuable.
任何帮助都是有价值的。
Problem solved.问题解决了。 In "Core" part of my TAF I used the wrong path to json file for setting up "FlurlHttp.GlobalSettings.Timeout" value.
在我的 TAF 的“核心”部分中,我使用了 json 文件的错误路径来设置“FlurlHttp.GlobalSettings.Timeout”值。 Instead of using ConfigManager class, I was using new configuration, that's why value for timeout was not found.
我没有使用 ConfigManager class,而是使用新配置,这就是找不到超时值的原因。 I updated my ConfigManager
我更新了我的 ConfigManager
and now everytning works fine in bitbucket CI
现在一切都在 bitbucket CI 中正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.