> For the complete documentation index, see [llms.txt](https://www.saladpuk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.saladpuk.com/software-testing/tdd101/automation-frameworks.md).

# 9.Automation Frameworks in .NET

💬 ถ้าถามว่าตัวที่ใช้เขียน automation testing ในฝั่ง .NET นั้นมีแค่ xUnit หรือเปล่า? คำตอบไม่ครับมีหลายตัวเลย ดังนั้นในรอบนี้ผมจะแนะนำ framework ที่ใช้ในการเขียน automation ที่นิยมๆของ .NET กันนะครับ

{% embed url="<https://www.youtube.com/watch?v=mLPSpGP8GwU&list=PLUjAn8nwWniiL3ToFK8PfmAo8U6IoGAkg&index=11>" %}

## 🎯 สรุปสั้นๆ

### 👨‍🚀 Framework ที่นิยมใช้ในฝั่ง .NET มี 3 ตัวเน่อ

1. [MSTest](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-mstest)
2. [NUnit](https://nunit.org/)
3. [xUnit](https://xunit.net/)

### 👨‍🚀 รูปแบบในการเขียน test (AAA)

1. **Arrange** อธิบายว่าสิ่งที่เราจะเทสคืออะไร
2. **Act** เขียนโค้ดให้มันไปเรียกส่วนที่เราจะทดสอบ
3. **Assert** ตรวจสอบผลลัพท์ที่ได้ว่ามันถูกต้องตามที่เราอยากให้มันเป็นหรือเปล่า

### 👨‍🚀 Code coverage

เป็นตัวชี้ว่าโค้ดที่เราเขียนนั้นมี test cases เข้าไปตรวจสอบทั้งหมดกี่ % แล้ว

{% hint style="warning" %}
การที่โค้ดของเราทุกส่วนมี test cases เข้าไปตรวจทั้งหมด 100% แล้วไม่ได้หมายความว่ามันจะไม่มี bug นะขอรับ
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.saladpuk.com/software-testing/tdd101/automation-frameworks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
