【发布时间】:2018-10-01 14:42:53
【问题描述】:
我是第一次尝试参考this article 的 python 单元测试。我的 Eclipse 中安装了 PyDev 插件。
我的test_hello.py 看起来像这样:
import unittest
class TestHello(unittest.TestCase):
def test_abc(self):
print("Test!!!")
result = True
self.assertEqual(result, True, "ohno")
当我Right click on source > Run As > Python unit-test时,它输出:
Finding files... done.
Importing test modules ... PYTHONPATH not found for file: D:\workspaces\python-ws\test\test_h
done.
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
同样在 PyUnit 选项卡中,它不显示任何内容:
我在这里缺少什么?
更新
添加更多细节:
我的项目:
PyDev 包浏览器
【问题讨论】:
-
你定义了测试,但它看起来不像你在调用你的函数 - 因此,什么都没有执行
-
我刚刚尝试在末尾添加
a = TestHello()和a.test_abc()。还是没用。 -
我也应该这样做吗?在 java 单元测试中,我们只需使用
@Test进行注释,它就可以工作。此外,所述文章似乎也没有这样做...... -
不确定,我以前从未使用过这个模块 - 也许其他人可以提供帮助
-
在我看来您的设置不正确。它说找不到
PYTONPATH。检查您的 eclipse 配置以验证它是否配置正确。
标签: python eclipse pydev python-unittest