With help from some friends I was able to solve this problem!
I moved the tSQLt.FakeTable command to a Setup.sql since tSQLt runs it before the other tests in that schema. We discovered this anomaly by running the FakeTable command and the INSERT INTO command in the same sql query. Like this:
EXEC [dbServername].tSQLt.FakeTable @TableName='vw_viewname', @SchemaName='dbo';
INSERT INTO [dbServername].dbo.vw_myView
(Column1, Column2, Column3, Column4, Column5, Column6, Column7)
VALUES ( '100513','C','2018-12-13','2019-03-25','2014-10-27',' ',40.500,'3');
That would cause the error:
[TestSchemaName].[Test usp_MyStuff_Get Get my stuff] failed: (Error) Update or insert of view or function 'dbServername.dbo.vw_myView' failed because it contains a derived or constant field.
This worked:
CREATE PROCEDURE [TestSchemaName].[Setup]
AS
BEGIN
IF @@TRANCOUNT > 0
BEGIN
EXEC [dbServername].tSQLt.FakeTable @TableName='vw_viewname', @SchemaName='dbo'
END
ELSE
BEGIN
RAISERROR('Procedure was run without tsqlt.Run. Aborting procedure', 16, 1)
END
END
CREATE PROCEDURE [TestSchemaName].[Test usp_MyStuff_Get Get my stuff]
AS
BEGIN
IF @@TRANCOUNT > 0
BEGIN
--EXEC [dbServername].tSQLt.FakeTable @TableName='vw_viewname', @SchemaName='dbo'
--I moved the line above to the Setup.sql
INSERT INTO [dbServername].dbo.vw_myView
(Column1, Column2, Column3, Column4, Column5, Column6, Column7)
VALUES ( '100513','C','2018-12-13','2019-03-25','2014-10-27',' ',40.500,'3')
END
ELSE
BEGIN
RAISERROR('Procedure was run without tsqlt.Run. Aborting procedure', 16, 1)
END
END
GO
Publish the project and then from SSMS run:
EXEC tsqlt.run '[TestSchemaName].[Test usp_MyStuff_Get Get my stuff]'