SQL 开发人员单元测试错误?
我决定开始在 PL/SQL 中使用单元测试,因为它可能很有趣并且可以提高代码的质量。
因此,我阅读了一些可用的资源,并选择了 SQL Developer 及其单元测试功能。
我遇到了一个愚蠢的问题,谷歌让我失败了。
我正在对一个简单的包进行单元测试。
--Package spec
CREATE OR REPLACE
PACKAGE SAMPLE_TEST
AS
TYPE SAMPLE_RECORD
IS
RECORD
(
SAMPLE_NUMBER NUMBER(3),
SAMPLE_DATE DATE,
SAMPLE_INTEGER INTEGER );
PROCEDURE DO_SOMETHING(
P_FILE VARCHAR2,
P_RESULT OUT SAMPLE_RECORD);
--OR FUNCTION (..) RETURN SAMPLE_RECORD...
END SAMPLE_TEST;
通过实现:
--Package body
CREATE OR REPLACE
PACKAGE BODY SAMPLE_TEST
AS
PROCEDURE SAMPLE_PROC(
P_FILE VARCHAR2,
P_RESULT OUT SAMPLE_RECORD)
AS
BEGIN
P_RESULT.SAMPLE_NUMBER := SUBSTR(P_FILE, 0 ,3);
P_RESULT.SAMPLE_DATE := TO_DATE(SUBSTR(P_FILE, 4 ,8), 'DD.MM.RRRR');
P_RESULT.SAMPLE_INTEGER := SUBSTR(P_FILE, 20);
END SAMPLE_PROC;
END SAMPLE_TEST;
输入字符串为035200220122102201213。
结果是 - 错误。断言失败。 该过程是正确的,它返回正确的值,但“单元测试框架”通知我:
P_RESULT : Expected: [<SAMPLE_NUMBER=35, SAMPLE_DATE=20.02.12, SAMPLE_INTEGER=13>],
Received: [<SAMPLE_NUMBER=35, SAMPLE_DATE=20.02.12, SAMPLE_INTEGER=13>]
我在任何地方都找不到提交的错误 - metalink、Google - 有什么想法吗?
I have decided to start using unit testing in PL/SQL, since it could be fun and improve the quality of the code.
So, Ive read several resources available and picked SQL Developer and its unit testing capabilities.
I ran into a stupid problem, and Google failed me.
I'm unit testing a simple package.
--Package spec
CREATE OR REPLACE
PACKAGE SAMPLE_TEST
AS
TYPE SAMPLE_RECORD
IS
RECORD
(
SAMPLE_NUMBER NUMBER(3),
SAMPLE_DATE DATE,
SAMPLE_INTEGER INTEGER );
PROCEDURE DO_SOMETHING(
P_FILE VARCHAR2,
P_RESULT OUT SAMPLE_RECORD);
--OR FUNCTION (..) RETURN SAMPLE_RECORD...
END SAMPLE_TEST;
With the implementation:
--Package body
CREATE OR REPLACE
PACKAGE BODY SAMPLE_TEST
AS
PROCEDURE SAMPLE_PROC(
P_FILE VARCHAR2,
P_RESULT OUT SAMPLE_RECORD)
AS
BEGIN
P_RESULT.SAMPLE_NUMBER := SUBSTR(P_FILE, 0 ,3);
P_RESULT.SAMPLE_DATE := TO_DATE(SUBSTR(P_FILE, 4 ,8), 'DD.MM.RRRR');
P_RESULT.SAMPLE_INTEGER := SUBSTR(P_FILE, 20);
END SAMPLE_PROC;
END SAMPLE_TEST;
The input string is 035200220122102201213.
The result is - an ERROR. Assertion failed.
The procedure is correct, it returns the correct values, but the "unit testing framework" informs me:
P_RESULT : Expected: [<SAMPLE_NUMBER=35, SAMPLE_DATE=20.02.12, SAMPLE_INTEGER=13>],
Received: [<SAMPLE_NUMBER=35, SAMPLE_DATE=20.02.12, SAMPLE_INTEGER=13>]
I can't find a submited bug anywhere - metalink, Google - any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此页面 https://forums.oracle.com/forums/thread.jspa?threadID =2382730
说引用游标和单元测试存在问题......
也许与其相关。
this page https://forums.oracle.com/forums/thread.jspa?threadID=2382730
says there is a problem with ref cursors and unit testing...
maybe its related.