我有 VS2022 解决方案和 2 个项目
我尝试过 ChatGPT 来寻求解决方案。但 ChatGPT 的一些建议不起作用。我为多家初创公司设置了解决方案。解决方案运行,WebAPI swagger 弹出,我看到文本资源管理器,看起来它正在运行 - 但我无法选择任何测试探索选项或调试测试。
ChatGPT 推荐了以下内容..但它不起作用,我无法选择或调试我的测试。他们还立即失败,说无法找到本地主机/端口。会不会是时间问题?
有什么想法可以与本地主机同时运行单元测试吗?
这是 ChatGPT 说明 - 但我无法选择测试资源管理器或调试测试。 有什么想法吗?
In Visual Studio 2022, you can run unit tests and run a localhost server simultaneously by following these steps:
Make sure your unit tests are set up correctly in your Visual Studio project. You should have a separate project or folder dedicated to unit tests.
Open your solution in Visual Studio 2022.
Right-click on the solution in the Solution Explorer and select "Properties" from the context menu.
In the properties window, go to the "Startup Project" tab.
Select the option "Multiple startup projects."
In the list of projects, select the project that contains your unit tests and the project that runs your localhost server. You can use Ctrl+Click to select multiple projects.
Set the action for both projects to "Start."
Click "Apply" and then "OK" to save the changes.
Press F5 or click the "Start" button to run your solution.
**Visual Studio will now start both the unit test project and the project running your localhost server simultaneously. You'll be able to see the output from both projects in the Output window, and you can interact with your localhost server while the unit tests are running.**
双击您的解决方案,以便在两个 Visual Studio 中打开您的项目,在其中一个上运行 API,在另一个上运行测试。