When I locally execute my mock test in c# then my test case gets passed but when I queue my build to azure then some of the random test cases fail which was getting passed locally? Any solution on this?
I got to know this was getting failed because my mock object was static. Check my another question Why my few test case get failed after "Running all" controller and pass individually?
Related
I am using cucumber-js for making e2e test. Once it failed, it's hard to debug due to ambiguous context of runtime. So I would like to have the ability to console log or take screenshot of what's going on when the testcase failed. Does cucumber support that and how can I do that in Cucumberjs
Scenario 1:
Given I got state A
When I do B <- fail here
Then I see C
// How can I run a logic when a step failed?
I'm using Azure's Runs API to get a pipeline run result as described here:
https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/get?view=azure-devops-rest-6.0#runresult
I can see in the documentation how to get the state and final result so I can know if the run was a success or a failure. However, in case of a failure, I don't see how I can get the error that occurred in that run as a string.
How can I get the actual error which caused the pipeline run to fail?
You can use the REST API "Timeline - Get" to list the issues (error and warning) associated with a run.
Note:
This API can only list the first 10 issues. If the run has more than 10 issues, the rest will not be listed in the response. To get the complete issues, you can use the API "Builds - Get Build Log" or "Logs - Get" to get the complete logs that contains the complete issues.
[UPDATE]
The buildId is same as the runId, and you can find it from the URL of the pipeline (build) run.
The timelineId is not required in the API request, you can use the request URI like as below.
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/timeline/?api-version=6.0
When I run (func run) the azure function project locally (VSCode) after I add azure function proxy I'm getting 'Worker was unable to load function" console error. However function locally run perfectly after that console error.
What could be the reason for that console error
Error
Worker was unable to load function get-user: 'TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received '''
The problem seems to be that the GUID of the function is generated but no real instance is generated. Therefore, trying to access the function GUID through proxy will report an error because it does not exist at all. I don't think you need to worry about this. This should be a bug, but the good news is that it will not have any effect on your function, because you will never use this GUID any more. A new instance and corresponding GUID will be generated when you trigger the function, and the previous GUID will be discarded.
I have a REST API and I'm writing TDD for this project. My TDD is consisted of two parts: route and service. I chose to use Jest. I have a MongoDB database that I use for testing. When each test is completed, I reset my database using the afterAll() method. In this method, I run the mongoose.connection.dropDatabase function.
There is no error when I ran only one test file but when I run multiple test files, I get an error. The error message:
MongoError: Cannot create collection auth-db.users - database is in
the process of being dropped.
I share sample codes with you:
users.route.test.ts:
https://gist.github.com/mksglu/8c4c4a3ddcb0e56782725d6457d97a0e
users.service.test.ts:
https://gist.github.com/mksglu/837202c1048687ad33b4d1dee01bd29c
When all my tests run, "sometimes" gives errors. I wrote the above error message. The reason for this error is that the reset process still continues. I can't solve this problem. I'd appreciate it if you could help.
Thanks.
https://jestjs.io/docs/en/cli.html#runinband
What you are looking for is --runInBand command. Which makes jest to run serially instead of creating a worker pool of child processes that run tests
When I run unit tests via Ospec for Mithril, I can see if tests fail locally in the console.
What I'm looking for is a solution that will not allow a following Node.js build script to execute if one or more of the tests fail.
I don't want code to be pushed up to another environment/lane if the unit tests aren't passing.
I don't see how to accomplish this in the docs.
In Node, I'm running ospec && someBuildProcess.
The answer might be a Node.js thing, but I'm at a loss for what to look for now.
ospec calls process.exit(1) if any tests fail, and the command string you posted should work. I just verified it locally with the following setup:
https://gist.github.com/tivac/d90c07592e70395639c63dd5100b50a6
ospec runs, fails, and the echo command never gets called.
Can you post some more details about your setup?