Options

Project Dependencies on Invoke-DatabaseTests

I have a solution for my database that includes one project for the DB objects I need in every environment (main project) and another project with all the testing objects (test project). As described in [1].

In my build script I use the PowerShell commandlets to Invoke-DatabaseBuild, New-DatabaseBuildArtifact, and Export-DatabaseBuildArtifact on main.sqlproj

In my test script I'm trying to use Invoke-DatabaseTests on test.sqlproj. However it errors and it is obvious that the main project is not being built and deployed before deploying the test project. (As I might have expected due to setting up a project build dependency)

What is the best practice for this or what have people found that works? 

[1] https://documentation.red-gate.com/sca3/tutorials/worked-examples/use-tsqlt-with-sql-change-automation-projects

Tagged:

Answers

  • Options
    ssvossssvoss Posts: 2 Bronze 1
    edited February 28, 2019 6:59PM
    I don't love it. I'd rather use the PowerShell Commandlets but I ended up using MSBuild to build/deploy the database to the server (can't use in memory since I have a full text index). Then I point Invoke-DatabaseTests directly at the testing database which already has the tests deployed to it.
    Exec { msbuild $SOLUTION /NoLogo /v:Minimal /t:Build /p:OutputPath=$outputDir 
    /p:Configuration=Release /p:DeploymentMode=DeployOnBuild 
    /p:ShadowServer=ServerName /p:ShadowUserName=$Uname /p:ShadowPassword=$Pass	
    /p:TargetServer=ServerName /p:TargetDatabase=TestingDatabase 
    /p:TargetUserName=$Uname /p:TargetPassword=$Pass} "Failed to build $_"
    
    $testResultsFile = "$env:WORKSPACE\out\tSQLtResults.junit.xml"
    $testResults = Invoke-DatabaseTests $testingDb
    Export-DatabaseTestResults $testResults -OutputFile $testResultsFile
    
  • Options
    Hi ssvoss,

    Thanks for posting on the Redgate forums.

    If you need any specifc help troubleshooting the errors please do post them here or create a support ticket at https://productsupport.red-gate.com/hc/en-us
    Kind regards,
    Dan Bainbridge
    Product Support Engineer | Redgate Software
Sign In or Register to comment.