You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode Test Explorer持续卡在测试发现状态无响应,输出显示测试已收集且终端运行测试正常

VSCode Test Explorer持续卡在测试发现状态无响应,输出显示测试已收集且终端运行测试正常

我最近在VSCode的Test Explorer上遇到了大麻烦,之前一直用得好好的,结果上周突然出问题了。当时我正在写新测试,点了“Refresh Tests”之后,它就毫无征兆地卡住了——一直显示“Discovering Tests”,永远停不下来。

VSCode Test Explorer 持续处于"Discovering Tests"状态

可奇怪的是,输出窗口明明显示测试已经被正确发现了:

测试输出窗口显示测试已成功发现

而且我用标准的pytest终端命令运行时,所有测试都能正常通过:

终端运行pytest显示所有测试通过

我的项目目录结构是这样的:

application
├── backend
│   ├── src
│   │   ├── __init__.py
│   │   ├── manage.py
│   │   ├── app1
│   │   │   ├── __init__.py
│   │   │   ├── folder1
│   │   │   │   ├── __init__.py
│   │   │   │   ├── views.py
│   │   │   │   ├── class1.py
│   │   │   │   ├── class2.py
│   │   │   │   ├── tests
│   │   │   │   │   ├── __init__.py
│   │   │   │   │   ├── test_class1.py
│   │   │   │   │   ├── test_class2.py
│   │   │   │   │   ├── test_views.py
│   │   │   ├── folder2
│   │   │   │   ├── __init__.py
│   │   │   │   ├── views.py
│   │   │   │   ├── class1.py
│   │   │   │   ├── class2.py
│   │   │   │   ├── tests
│   │   │   │   │   ├── __init__.py
│   │   │   │   │   ├── test_class1.py
│   │   │   │   │   ├── test_class2.py
│   │   │   │   │   ├── test_views.py
│   │   │   ├── app2
│   │   │   │   ├── ...
│   ├── pytest.ini
│   ├── Dockerfile
│   ├── Dockerfile.dev

我当前的settings.json配置是这样的——我已经按照Stack Overflow上的各种文章试了好多种不同的设置,但都不管用:

VSCode settings.json中的pytest相关配置

还有个更烦人的问题:我没办法取消或者重启测试发现。一旦尝试这么做,就会弹出错误提示说测试发现已经在运行了,无法重启:

尝试重启测试发现时的错误提示

真的快被逼疯了,希望有人能帮我解决这个问题😭

备注:内容来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 13:04:32