plunit测试显然在后台创建了一个模块……但是可以卸载该模块吗?

问题描述 投票:0回答:1

我想使用SWI Prolog中实现的plunit来以优雅的风格运行一些单元测试!

所以我想直接在终端上输入它们:

[user].

然后复制粘贴:

:- begin_tests(exercise).

test(foo) :- bar.

:- end_tests(exercise).

这很好用。

...但是如果我再次通过[user].加载测试,则会有类似Westworld的体验:

?- [user].
|: :- begin_tests(exercise).

ERROR: user://2:17:
ERROR:    module/2: No permission to redefine module `plunit_exercise' (Already loaded from user://1)
Warning: user://2:17:
Warning:    Goal (directive) failed: user:begin_tests(exercise)

似乎该实现为测试plunit_X创建了一个模块X。很有道理。

但是有什么方法可以卸载测试模块exercise

必须有...

注意,您可以使用unload_file/1卸载file,但不能卸载模块?

unit-testing module prolog swi-prolog
1个回答
0
投票

由于我不知道如何重现您的问题,因此您必须自己进行测试。

使用destroy_module/1

因为它不是从模块modules]中导出的,所以我猜测module:destroy_module(X)应该可以工作。

因为它不是公共模块,也没有文档Caveat emptor

© www.soinside.com 2019 - 2024. All rights reserved.