私はいくつかのtSQLtテストを書いており、Visual Studioのテストエクスプローラを使ってtSQLt test adapterエクステンションを使ってそれらを実行しています。私はTDDをやっているので、テストするストアドプロシージャを書く前にテストを書いています。Visual StudioテストエクスプローラでtSQLtテストが失敗すると、なぜテストに合格するのですか?
問題は、テストを実行すると、ストアドプロシージャがまだ存在しないために失敗するはずです。ここで
:私はテストエクスプローラでそれを実行すると
The module 'test_ValidCustomerName_CustomerIdIs1' depends on the missing object 'dbo.AddCustomer'. The module will still be created; however, it cannot run successfully until the object exists.
(0 row(s) affected)
[AddCustomer].[test_ValidCustomerName_CustomerIdIs1] failed: (Error) Could not find stored procedure 'dbo.AddCustomer'.[16,62]{test_ValidCustomerName_CustomerIdIs1,7}
+----------------------+
|Test Execution Summary|
+----------------------+
|No|Test Case Name |Dur(ms)|Result|
+--+----------------------------------------------------+-------+------+
|1 |[AddCustomer].[test_ValidCustomerName_CustomerIdIs1]| 0|Error |
-----------------------------------------------------------------------------
Msg 50000, Level 16, State 10, Line 1
Test Case Summary: 1 test case(s) executed, 0 succeeded, 0 failed, 1 errored.
-----------------------------------------------------------------------------
をしかし、それはテストに合格したと言う:私は、SQL Server Management StudioでtSQLtを使用してテストを実行するとそれが必要のように、それは失敗しますテストのためのコードは次のとおりです。
EXEC tSQLt.NewTestClass 'AddCustomer';
GO
CREATE PROCEDURE AddCustomer.test_ValidCustomerName_CustomerIdIs1
AS
BEGIN
DECLARE @customerName NVARCHAR(40) = 'John Doe'
EXEC dbo.AddCustomer @customerName
DECLARE @expected INT = 1
, @actual INT = (SELECT CustomerID
FROM dbo.Customer
WHERE Name = @customerName)
EXEC tSQLt.AssertEquals @expected, @actual
END
GO
そして、ここではdbo.Customer
表は次のとおりです。
CREATE TABLE dbo.Customer
(
CustomerID INT NOT NULL PRIMARY KEY IDENTITY(1, 1)
, Name NVARCHAR(50) NOT NULL
)
EDIT - 私はちょうどtSQLt.Fail
を呼び出すためのテスト変更した:
EXEC tSQLt.NewTestClass 'AddCustomer';
GO
CREATE PROCEDURE AddCustomer.test_ValidCustomerName_CustomerIdIs1
AS
BEGIN
EXEC tSQLt.Fail 'Test should fail'
END
GO
テストはまだテストエクスプローラでを渡しSQL Server Management Studioを、それに失敗しています。
はLewsねえ - 私はこの正確な事を試してみましたが、それが私の作品 - あなたは私にあなたが使用しているSQL ServerとVisual Studioのバージョンを伝えることができますか? –
@EdElliottご覧いただきありがとうございます。私はSQL Server 2008 R2とVisual Studio 2015 Enterprise Update 3を使用しています。 –