如何在具有覆盖率的void函数上执行单元测试

时间:2019-02-10 06:11:44

标签: java unit-testing mockito

我是单元测试的新手。
我正在尝试对以下代码进行单元测试

{
    "name": "error",
    "length": 189,
    "severity": "ERROR",
    "code": "42601",
    "internalPosition": "8",
    "internalQuery": "SELECT *",
    "where": "PL/pgSQL function insertintoinstancedlist() line 15 at RETURN",
    "file": "parse_target.c",
    "line": "1290",
    "routine": "ExpandAllTables"
}


CREATE OR REPLACE FUNCTION 
    insertIntoInstancedList () 
RETURNS TRIGGER AS $BODY$
DECLARE
BEGIN
    INSERT INTO
        creator.instanced_lists
        (
            list_id,
            account_id
        )
    VALUES
        (
            new._id,
            new.account_id
        );
    RETURN
        *;
END
$BODY$
language plpgsql;        

CREATE TRIGGER trig_list_insertion
    AFTER INSERT ON creator.lists
    FOR EACH ROW
    EXECUTE PROCEDURE insertIntoInstancedList();


如何对这种方法进行单元测试?

1 个答案:

答案 0 :(得分:1)

我会嘲笑此消息对象和Verify的调用时间。

更多信息和示例,您可以找到here

Same problem