This repository contains a C# solution for analyzing test results stored in a JSON file, generating metrics based on the results, and exporting them to a CSV file.
To test the provided C# script, follow these steps:
-
Clone the Repository: Clone this repository to your local machine using Git.
git clone https://github.com/your-username/test-results-analysis.git
-
Navigate to the Directory: Move into the directory containing the cloned repository.
cd test-results-analysis -
Prepare JSON Data: Create a JSON file named
test_results.jsonwith test results data. You can use the provided example or create your own.Example JSON file content:
{ "Results": [ { "TestCase": "Test 1", "Status": "pass", "ExecutionTime": 10, "Timestamp": "2024-03-13T12:00:00Z" }, { "TestCase": "Test 2", "Status": "fail", "ExecutionTime": 15, "Timestamp": "2024-03-13T12:05:00Z" }, { "TestCase": "Test 3", "Status": "pass", "ExecutionTime": 8, "Timestamp": "2024-03-13T12:10:00Z" } ] } -
Compile the C# Script: Use the C# compiler (csc) to compile the script into an executable.
csc /out:TestResultsAnalyzer.exe TestResultsAnalyzer.cs /r:Newtonsoft.Json.dll
Make sure you have the C# compiler installed and the Newtonsoft.Json.dll assembly present in the same directory or adjust the path in the command accordingly.
-
Run the Program: Execute the compiled program.
TestResultsAnalyzer.exe
-
View Output: Check the console output for the generated metrics.
Example output:
Metrics: Total number of test cases executed: 3 Number of test cases passed: 2 Number of test cases failed: 1 Average execution time for all test cases: 11 seconds Minimum execution time among all test cases: 8 seconds Maximum execution time among all test cases: 15 seconds -
Verify CSV File: Check the generated CSV file (
test_results.csv) for the detailed test results.
- Ensure that the provided JSON file contains valid test results data in the specified format.
- Make sure to have the required dependencies installed and available for compilation and execution.
- Feel free to modify the provided script or JSON data for testing different scenarios.