在被测试对象和测试脚本之间建立依赖关系,确保被测试对象能够访问测试脚本中引用的库。
例如,在Python中,可以使用sys.path.append()方法将库的路径添加到系统路径中,以便被测试对象可以使用这些库。示例如下:
#测试脚本 import sys sys.path.append('/path/to/library') from library_name import function_name
#被测试对象 class TestObject: def test_method(self): result = function_name() assert result == expected_result