Suresh
Suresh

Reputation: 59

.NET UnitTest Project Build and Test in DevOps pipeline failed?

I have written the unit test, All the unit tests in this solution require a database connection

I have Created VSTS devops build and test pipeline but failed tests for database connection.

UnitTest functionality working fine in local but VSTS Devops unittest failed. kindly refer below screen

Kindly give me any idea to solve this issue.

enter image description here

Thanks

Upvotes: 0

Views: 456

Answers (2)

Suresh
Suresh

Reputation: 59

Working fine, Configured based on the below link - https://www.dotnetcurry.com/visualstudio/1456/integration-testing-sqllocaldb

Thanks.

Upvotes: 0

Andrei Dragotoniu
Andrei Dragotoniu

Reputation: 6335

the error message is clearly saying that it cannot connect to that database. Just because you can establish the connection from your local machine that doesn't mean that another environment can also connect to the same db. You need to make sure that the server you deployed to, can connect using that connection string.

Now, you keep saying unit tests. Unit tests are not meant to connect to databases, what you have are integration tests. Issues like this are one of the reasons why unit tests are meant to not use any kind of external things, they are meant to test functionality and not work with real databases.

Upvotes: 2

Related Questions