Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"permissions": {
"allow": [
"Bash(dotnet build:*)",
"Bash(dotnet test:*)",
"Bash(docfx:*)",
"Bash(dir:*)",
"Bash(grep:*)"
],
"deny": [],
"ask": []
}
}
68 changes: 68 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

This is the NUnit documentation repository that serves content at <https://docs.nunit.org>. It's a DocFX-based static site generator that builds documentation from markdown files and generates API documentation from .NET assemblies.

## Architecture

- **docs/**: Main documentation content including articles, markdown files, and DocFX configuration
- **docs/docfx.json**: Primary DocFX configuration file that defines build settings, metadata, and site structure
- **docs/snippets/**: .NET solution (Snippets.sln) containing C# code snippets used in documentation
- **code-output/**: Directory where NUnit release assemblies are placed for API documentation generation
- **legacy/**: Legacy documentation content served as static resources
- **.devcontainer/**: Docker-based development environment with pre-configured tools

## Development Commands

### DevContainer/Codespaces (Recommended)

- `build` - Build the documentation site using DocFX
- `serve` - Build and serve the site locally at <http://localhost:8080>
- `lint` - Run markdown linting using markdownlint-cli2
- `spellcheck` - Run spell checking using cspell
- `snippets` - Build and test the code snippets solution
- `apidocs` - Download latest NUnit API documentation

### Local Development (requires docfx installed)

- `docfx docs/docfx.json` - Build the site
- `docfx docs/docfx.json --serve` - Build and serve locally
- `markdownlint-cli2 --config ".github/linters/.markdownlint.yml" "docs/**/*.md"` - Lint markdown
- `cspell --config cSpell.json "docs/**/*.md" --no-progress` - Spell check
- `dotnet test docs/snippets/Snippets.sln` - Test code snippets

## Key Configuration Files

- **docs/docfx.json**: DocFX build configuration, metadata generation, and site settings
- **cSpell.json**: Spell checker dictionary and configuration
- **.github/linters/.markdownlint.yml**: Markdown linting rules
- **.markdownlintrc**: Additional markdown lint configuration
- **docs/filterConfig.yml**: API documentation filtering rules

## Documentation Structure

- **docs/articles/**: Main documentation content organized by topic
- **docs/api/**: Generated API documentation (auto-generated from code-output assemblies)
- **docs/legacy/**: Legacy documentation served as static files
- **docs/images/**, **docs/css/**, **docs/js/**: Static assets
- **docs/toc.yml**: Main table of contents structure

## Code Snippets

The repository includes a .NET solution at `docs/snippets/Snippets.sln` containing:

- **Snippets.NUnit**: NUnit framework code examples
- **Snippets.NUnitLite**: NUnit Lite framework examples

Code snippets are tested as part of the build process to ensure documentation examples remain valid.

## API Documentation Generation

API docs are generated from NUnit release assemblies placed in the `code-output/` directory. The DevContainer automatically downloads the latest release, or assemblies can be manually extracted from NUnit GitHub releases.

## Deployment

The site is built and deployed via GitHub Actions to the `gh-pages` branch, which serves <https://docs.nunit.org>.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ ClassicAssert.AreEqual(object expected, object actual,
The method overloads that compare two objects make special provision so that numeric
values of different types compare as expected. This assert succeeds:

```csharp
ClassicAssert.AreEqual(5, 5.0);
```
[!code-csharp[AreEqualExamples](~/snippets/Snippets.NUnit/ClassicAssertExamples.cs#AreEqualExamples)]

## Comparing Floating Point Values

Expand All @@ -29,11 +27,7 @@ as equal.

Special values are handled so that the following Asserts succeed:

```csharp
ClassicAssert.AreEqual(double.PositiveInfinity, double.PositiveInfinity);
ClassicAssert.AreEqual(double.NegativeInfinity, double.NegativeInfinity);
ClassicAssert.AreEqual(double.NaN, double.NaN);
```
[!code-csharp[AreEqualExamples](~/snippets/Snippets.NUnit/ClassicAssertExamples.cs#AreEqualExamples)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SeanKilleen The same examples are shown on both line 20 and line 30.
The text might need adjusting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks, missed this 👍 I'll do a pass on the published site soon for inconsistencies.


## Comparing Arrays and Collections

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ ClassicAssert.IsTrue(bool condition, string message, params object[] params);
You can also use **Assert.That** with a Boolean argument to achieve the
same result.

```csharp
Assert.That(condition);
```
[!code-csharp[TrueExamples](~/snippets/Snippets.NUnit/ClassicAssertExamples.cs#TrueExamples)]

## See Also

Expand Down
43 changes: 3 additions & 40 deletions docs/articles/nunit/writing-tests/attributes/category.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,11 @@ selected categories will be run. Those tests in categories that are not selected

## Test Fixture Syntax

```csharp
namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture]
[Category("LongRunning")]
public class LongRunningTests
{
// ...
}
}
```
[!code-csharp[CategoryTestFixtureExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#CategoryTestFixtureExample)]

## Test Syntax

```csharp
namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture]
public class SuccessTests
{
[Test]
[Category("Long")]
public void VeryLongTest()
{ /* ... */ }
}
```
[!code-csharp[CategoryTestExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#CategoryTestExample)]

### Custom Category Attributes

Expand All @@ -52,14 +25,4 @@ of CategoryAttribute sets the category name to the name of your class.
Here's an example that creates a category of Critical tests. It works just like any other category, but has a simpler
syntax. A test reporting system might make use of the attribute to provide special reports.

```csharp
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public class CriticalAttribute : CategoryAttribute
{ }
```

```csharp
[Test, Critical]
public void MyTest()
{ /*...*/ }
```
[!code-csharp[CustomCategoryAttribute](~/snippets/Snippets.NUnit/AttributeExamples.cs#CustomCategoryAttribute)]
18 changes: 1 addition & 17 deletions docs/articles/nunit/writing-tests/attributes/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,7 @@ XML output file.

## Example

```csharp
[assembly: Description("Assembly description here")]

namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture, Description("Fixture description here")]
public class SomeTests
{
[Test, Description("Test description here")]
public void OneTest()
{ /* ... */ }
}
}
```
[!code-csharp[DescriptionTestExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#DescriptionTestExample)]

> [!NOTE]
> The Test and TestFixture attributes continue to support an optional Description property. The Description
Expand Down
17 changes: 1 addition & 16 deletions docs/articles/nunit/writing-tests/attributes/ignore.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,7 @@ namespace NUnit.Tests

## Test Syntax

```csharp
namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture]
public class SuccessTests
{
[Test]
[Ignore("Ignore a test")]
public void IgnoredTest()
{ /* ... */ }
}
}
```
[!code-csharp[IgnoreTestExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#IgnoreTestExample)]

## Ignore Until

Expand Down
10 changes: 1 addition & 9 deletions docs/articles/nunit/writing-tests/attributes/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ public RangeAttribute(double from, double to, double step);

The following test will be executed nine times.

```csharp
[Test]
public void MyTest(
[Values(1, 2, 3)] int x,
[Range(0.2, 0.6, 0.2)] double d)
{
/* ... */
}
```
[!code-csharp[RangeAttributeExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#RangeAttributeExample)]

The MyTest method is called nine times, as follows:

Expand Down
21 changes: 1 addition & 20 deletions docs/articles/nunit/writing-tests/attributes/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,7 @@ If a SetUp method fails or throws an exception, the test is not executed and a f

## Example

```csharp
namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture]
public class SuccessTests
{
[SetUp] public void Init()
{ /* ... */ }

[TearDown] public void Cleanup()
{ /* ... */ }

[Test] public void Add()
{ /* ... */ }
}
}
```
[!code-csharp[SetUpTearDownExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#SetUpTearDownExample)]

## Inheritance

Expand Down
24 changes: 3 additions & 21 deletions docs/articles/nunit/writing-tests/attributes/values.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ test method itself.

## Example

```csharp
[Test]
public void MyTest([Values(1, 2, 3)] int x, [Values("A", "B")] string s)
{
/* ... */
}
```
[!code-csharp[ValuesAttributeExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#ValuesAttributeExample)]

The above test will be executed six times, as follows:

Expand All @@ -43,24 +37,12 @@ The values attribute works in a special way with Enums and Boolean parameters.
When used without any arguments, the **[Values]** attribute on an enum parameter
will automatically include all possible values of the enumeration.

```csharp
[Test]
public void MyEnumTest([Values]MyEnumType myEnumArgument)
{
//...
}
```
[!code-csharp[ValuesAttributeEnumExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#ValuesAttributeEnumExample)]

There is the same support for Boolean values. Add the **[Values]** attribute to a bool
and the method will be run with true and false.

```csharp
[Test]
public void MyBoolTest([Values]bool value)
{
//...
}
```
[!code-csharp[ValuesAttributeBoolExample](~/snippets/Snippets.NUnit/AttributeExamples.cs#ValuesAttributeBoolExample)]

## See also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ AndConstraint(Constraint left, Constraint right)

## Examples of Use

```csharp
Assert.That(2.3, Is.GreaterThan(2.0).And.LessThan(3.0));
```
[!code-csharp[AndConstraintExamples](~/snippets/Snippets.NUnit/ConstraintExamples.cs#AndConstraintExamples)]

## Evaluation Order and Precedence

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ Does.Contain(object)

## Examples of Use

```csharp
int[] iarray = new int[] { 1, 2, 3 };
string[] sarray = new string[] { "a", "b", "c" };
Assert.That(iarray, Has.Member(3));
Assert.That(sarray, Has.Member("b"));
Assert.That(sarray, Contains.Item("c"));
Assert.That(sarray, Has.No.Member("x"));
Assert.That(iarray, Does.Contain(3));
```
[!code-csharp[CollectionContainsExamples](~/snippets/Snippets.NUnit/ConstraintExamples.cs#CollectionContainsExamples)]

## Note

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ With NUnit 3.6, an enhanced syntax is available that allows expressing the delay
```

Only Minutes, Seconds and MilliSeconds (note capital-S) are accepted as time modifiers. The default is to use MilliSeconds.

## Examples of Use

[!code-csharp[DelayedConstraintExamples](~/snippets/Snippets.NUnit/ConstraintExamples.cs#DelayedConstraintExamples)]
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ Is.Empty

## Examples of Use

```csharp
Assert.That("", Is.Empty);
Assert.That(new Dictionary<int, int>(), Is.Empty);
Assert.That(new List<string>(), Is.Empty);
```
[!code-csharp[EmptyConstraintExamples](~/snippets/Snippets.NUnit/ConstraintExamples.cs#EmptyConstraintExamples)]

## Notes

Expand Down
Loading
Loading