我想写一个单元测试,如下图所示:
-- Test name
SET @TestName = 'EastersMonday'
-- Set unit-test StartTime
SET @UnitTestStart = GETDATE()
-- Result
SET @RequiredResult = 20180402
-- Method call
SET @FunctionResult = DWH_Staging.dim.GetEasters (@Year = 2018, @Day = 'Monday', @CountryID = 1) -- "An insufficient number of parameters were supplied..."
-- Evaluation
SELECT @TestResult = IIF(@RequiredResult = @@ROWCOUNT,1,0)
-- Set unit-test EndTime
SET @UnitTestEnd = GETDATE()
-- Log
INSERT INTO @Result (TestName,TestResult,TestStart,TestEnd) VALUES (@TestName,@TestResult,@UnitTestStart,@UnitTestEnd)
到标量函数,定义为
CREATEFUNCTION [dim].[GetEasters](@Year AS INTEGER,@Day VARCHAR(15),@CountryID TINYINT)
RETURNS INT
单元测试解析器引发错误
"提供的参数数量不足......"
这很好用:
DECLARE @Result int
SET @Result = dim.GetEasters(2018, 'Monday', 1)
SELECT @Result
我做错了什么?