मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग40k · #7154

csharp-nunit

यह क्या करती है

यह टूल NUnit का इस्तेमाल करके आपके कोड के लिए अच्छे टेस्ट लिखने में मदद करता है। यह आम टेस्ट और अलग-अलग data वाले टेस्ट, दोनों के सबसे अच्छे तरीके सिखाता है।

कब इस्तेमाल करें

  • ✓जब आप सुनिश्चित करना चाहते हों कि आपका कोड सही काम करता है।
  • ✓जब ऐसे टेस्ट बनाने हों जिन्हें कई अलग-अलग data inputs चाहिए।
  • ✓अपने टेस्ट को व्यवस्थित और एक जैसे मानकों (standard) में रखने के लिए।

Skill का लिंक

https://github.com/github/awesome-copilot/blob/main/skills/csharp-nunit/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/github/awesome-copilot/blob/main/skills/csharp-nunit/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मैं एक sum function के लिए टेस्ट कैसे लिखूँ जो जाँचे कि 2 + 2 = 4 है?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह टूल बताता है कि आपकी टेस्ट files को कैसे व्यवस्थित करें, अपने टेस्ट को साफ़ नाम कैसे दें, और टेस्ट को सेट अप और चलाने के लिए खास attributes कैसे इस्तेमाल करें।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

NUnit Best Practices

Your goal is to help me write effective unit tests with NUnit, covering both standard and data-driven testing approaches.

Project Setup

  • Use a separate test project with naming convention [ProjectName].Tests
  • Reference Microsoft.NET.Test.Sdk, NUnit, and NUnit3TestAdapter packages
  • Create test classes that match the classes being tested (e.g., CalculatorTests for Calculator)
  • Use .NET SDK test commands: dotnet test for running tests

Test Structure

  • Apply [TestFixture] attribute to test classes
  • Use [Test] attribute for test methods
  • Follow the Arrange-Act-Assert (AAA) pattern
  • Name tests using the pattern MethodName_Scenario_ExpectedBehavior
  • Use [SetUp] and [TearDown] for per-test setup and teardown
  • Use [OneTimeSetUp] and [OneTimeTearDown] for per-class setup and teardown
  • Use [SetUpFixture] for assembly-level setup and teardown

Standard Tests

  • Keep tests focused on a single behavior
  • Avoid testing multiple behaviors in one test method
  • Use clear assertions that express intent
  • Include only the assertions needed to verify the test case
  • Make tests independent and idempotent (can run in any order)
  • Avoid test interdependencies

Data-Driven Tests

  • Use [TestCase] for inline test data
  • Use [TestCaseSource] for programmatically generated test data
  • Use [Values] for simple parameter combinations
  • Use [ValueSource] for property or method-based data sources
  • Use [Random] for random numeric test values
  • Use [Range] for sequential numeric test values
  • Use [Combinatorial] or [Pairwise] for combining multiple parameters

Assertions

  • Use Assert.That with constraint model (preferred NUnit style)
  • Use constraints like Is.EqualTo, Is.SameAs, Contains.Item
  • Use Assert.AreEqual for simple value equality (classic style)
  • Use CollectionAssert for collection comparisons
  • Use StringAssert for string-specific assertions
  • Use Assert.Throws<T> or Assert.ThrowsAsync<T> to test exceptions
  • Use descriptive messages in assertions for clarity on failure

Mocking and Isolation

  • Consider using Moq or NSubstitute alongside NUnit
  • Mock dependencies to isolate units under test
  • Use interfaces to facilitate mocking
  • Consider using a DI container for complex test setups

Test Organization

  • Group tests by feature or component
  • Use categories with [Category("CategoryName")]
  • Use [Order] to control test execution order when necessary
  • Use [Author("DeveloperName")] to indicate ownership
  • Use [Description] to provide additional test information
  • Consider [Explicit] for tests that shouldn't run automatically
  • Use [Ignore("Reason")] to temporarily skip tests
अक्सर पूछे जाने वाले सवाल

unit tests क्या होते हैं?

ये छोटे टेस्ट होते हैं जो जाँचते हैं कि आपके कोड का कोई खास हिस्सा (कोई function या method) अपेक्षा के अनुसार काम करता है या नहीं।

NUnit क्या है?

यह C# में टेस्ट लिखने के लिए इस्तेमाल होने वाली एक लोकप्रिय library है।

'data-driven' टेस्ट क्या होते हैं?

ये ऐसे टेस्ट होते हैं जो अलग-अलग data सेट के साथ कई बार चलते हैं, बिना एक ही टेस्ट को बार-बार लिखे।

जानकारी

लेखक का मूल विवरण

Get best practices for NUnit unit testing, including data-driven tests

repo: github/awesome-copilot

लोकप्रियता

GitHub स्टार
40k
रैंकिंग में स्थान
#7154
लाइसेंस
MIT
अपडेट की गई
15/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

acquire-codebase-knowledge

40k

आपके एजेंट को किसी मौजूदा code प्रोजेक्ट को समझने और उसका documentation बनाने में मदद करता है। यह नए लोगों को प्रोजेक्ट से जोड़ने या architecture का सार जानने में उपयोगी है।

लेखन और डॉक्यूमेंटडॉक्यूमेंटेशन

acreadiness-assess

40k

आपके एजेंट को किसी प्रोजेक्ट की AI के लिए तैयारी जाँचने और रिपोर्ट बनाने देता है। यह समझने में उपयोगी है कि प्रोजेक्ट AI tools इस्तेमाल करने के लिए कितना तैयार है।

लेखन और डॉक्यूमेंटडॉक्यूमेंटेशन

acreadiness-generate-instructions

40k

आपके एजेंट को assessment के आधार पर AI tools के लिए निर्देश बनाने में मदद करता है। यह बताता है कि AI कोड के साथ बेहतर कैसे काम करे और पहचानी गई कमियाँ कैसे दूर हों।

लेखन और डॉक्यूमेंटडॉक्यूमेंटेशन

acreadiness-policy

40k

आपके एजेंट को AI प्रोजेक्ट assessment के लिए नीतियाँ तय करने या लागू करने में मदद करता है। यह प्रोजेक्ट्स के मूल्यांकन को मानक बनाने और compliance सुनिश्चित करने में उपयोगी है।

AI और एजेंटएजेंट

मिलती-जुलती skills