Automation testing framework (API) - an example. Based on C#, .Net8, MSTest, XUnit, Refit
This testing framework to test REST API for https://jsonplaceholder.typicode.com. Simple calls like GET, PATCH, DELETE.
.Net8, Refit 8.0.0,
MSTest
XUnit
-- automaton-v27
`-- .github
`-- workflows
|-- dotnet-mstest.yml
|-- dotnet-xunit.yml
`-- ClientApi
|-- ClientApi.csproj
|-- ClientApi.sln
|-- IApiClient.cs
|-- PostCommentResponse.cs
|-- PostResponse.cs
`-- MSTestTestFramework
|-- ClientApiTest.cs
|-- GlobalUsing.cs
|-- MSTestTestFramework.csproj
|-- MSTestTestFramework.sln
`-- MSTestTestFramework
|-- ClientApiTest.cs
|-- GlobalUsing.cs
|-- XUnitTestFramework.csproj
|-- XUnitTestFramework.sln
|-- .gitignore
|-- LICENSE
|-- README.md
This section explains how to set up the project locally and run the tests.
-
Open your terminal or command prompt.
-
Navigate to the directory where you want to clone the project.
-
Run the following command:
git clone https://github.com/BurhanH/automaton-v27.git
-
Change into the cloned directory:
cd automaton-v27
This project uses .NET 8. Ensure you have the .NET 8 SDK installed. You can download it from here.
Once the SDK is installed, open your terminal in the root directory of the cloned project and run the following command to restore the necessary packages for all projects (ClientApi, MSTestTestFramework, and XUnitTestFramework):
dotnet restore ClientApi/ClientApi.sln && dotnet restore MSTestTestFramework/MSTestTestFramework.sln && dotnet restore XUnitTestFramework/XUnitTestFramework.slnOr, if you are in the root of the repository, you can also restore all projects by iterating through solution files:
for sln_file in $(find . -name '*.sln'); do dotnet restore $sln_file; doneYou can run tests using either MSTest or XUnit. Make sure you are in the root directory of the project in your terminal.
To run the MSTest tests, navigate to the MSTest project directory and use the dotnet test command:
cd MSTestTestFramework
dotnet test
cd .. This command will discover and execute all tests within the MSTestTestFramework project.
To run the XUnit tests, navigate to the XUnit project directory and use the dotnet test command:
cd XUnitTestFramework
dotnet test
cd ..This command will discover and execute all tests within the XUnitTestFramework project.
We welcome contributions to improve and expand this testing framework! If you'd like to contribute, please follow these general steps:
-
Fork the Repository: Start by forking the main repository to your own GitHub account.
-
Create a New Branch: Before making any changes, create a new branch in your forked repository. This helps keep your changes organized and separate from the
mainbranch. Choose a descriptive branch name (e.g.,feature/add-new-endpoint-tests,bugfix/fix-auth-issue).git checkout -b your-branch-name
-
Make Your Changes: Implement your feature, fix the bug, or improve the documentation. Ensure your code adheres to the existing style and that you add or update tests as necessary.
-
Commit Your Changes: Once you're satisfied with your changes, commit them with a clear and concise commit message.
git add . git commit -m "Your descriptive commit message"
-
Push to Your Fork: Push your new branch and its commits to your forked repository on GitHub.
git push origin your-branch-name
-
Submit a Pull Request (PR): Go to the original repository on GitHub and open a new pull request. Select your forked repository's branch to be merged into the main repository's
mainbranch (or the appropriate target branch). Provide a clear title and description for your PR, outlining the changes you've made and why. -
Discussion and Review: Your PR will be reviewed, and there might be some discussion or requests for changes. Once everything is approved, your contribution will be merged.
Thank you for your interest in contributing!