Is there a way to test method crash in C#?. I need an implementation method in c# for ExpectedSystemExit(available in Java) and ASSERT_DEATH(available in google test).
Is there a way to test method crash in C#?. I need an implementation method in c# for ExpectedSystemExit(available in Java) and ASSERT_DEATH(available in google test).
When you say method crash do you mean to test if the code you're calling throws an exception, or do you mean if the test host program has exited?
I want to test the condition where the test host program exits with a non-zero exit code.
If the test host exits then it wouldn't be able to test it's own exit code. It only really makes sense to test the exit code of another process.
You could spawn a new process using the Process class:
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=net-5.0
var process = new Process();
process.StartInfo = ...
process.Start();
process.WaitForExit();
Assert.Equal(1, process.ExitCode); // Exited with error
7 people are following this question.
Insert a node as child ,before or after a node in nested dynamic JSON Node using C#
Visual Studio 2019: Undefined behavior in a C++/CLI wrapper project.
Example for how to get Package Metadata from Azure DevOps Rest-Api Artifacts using c#
How to collapse individual nested grids/stackpanels inside a grid?