Skip to content
Development
Command

/test-dotnet

Run .NET/C# tests for Unity projects and backend services

From plugin
solana-ai-kit
10130 skills15 agents30 commands7 MCP
Install
> /plugin marketplace add solanabr/solana-ai-kit
> /plugin install solana-ai-kit@stbr

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/test-dotnet

Context preview

What this command does when you run it.

Run .NET/C# tests for Unity projects and backend services

Command definition

test-dotnet.md
description: "Run .NET/C# tests for Unity projects and backend services"

You are running .NET/C# tests. This command covers Unity Test Framework (Edit Mode and Play Mode) and standard .NET testing.

Related Skills

  • [solana-game SKILL.md](../skills/ext/solana-game/skill/SKILL.md) - Unity patterns, testing + PlaySolana specifics

---

TDD Workflow (6 Phases)

When developing with TDD, follow these phases strictly:

Phase 1: RED - Write Failing Test

1. Create test file in appropriate location (`Tests/EditMode/` or `Tests/PlayMode/`) 2. Write minimal test that fails for the right reason 3. Run test to confirm it fails 4. **Do NOT write production code yet**

[Test]
public void Calculate_WithValidInput_ReturnsExpected()
{
    var sut = new Calculator();  // Class doesn't exist yet

    var actual = sut.Calculate(10, 2);

    Assert.That(actual, Is.EqualTo(12));
}

Phase 2: GREEN - Make Test Pass

1. Write minimal production code to pass the test 2. **Only write enough code to pass** - no more 3. Run test to confirm it passes 4. Commit if green

public class Calculator
{
    public int Calculate(int a, int b) => a + b;  // Minimal implementation
}

Phase 3: REFACTOR - Clean Up

1. Improve code structure without changing behavior 2. Run tests after each refactoring step 3. Keep tests green throughout 4. Apply SOLID principles, remove duplication

Phase 4: Iterate

1. Return to Phase 1 for next test case 2. Build up functionality incrementally 3. Each cycle: RED → GREEN → REFACTOR

Phase 5: Integration

1. After unit tests pass, run integration tests 2. Test component interactions 3. For Unity: run Play Mode tests

Phase 6: Review

1. Review test coverage 2. Check for missing edge cases 3. Ensure tests are maintainable 4. Remove any redundant tests

---

Core Workflow: Build → Respond → Iterate

Operate in fast, surgical development cycles with minimal token usage.

Execution Flow

1. **Understand the Request**: Analyze minimum code required 2. **Make the Change**: Implement surgical edit 3. **Build**: `dotnet build --no-restore --nologo --verbosity minimal` 4. **If Build Fails**: Retry once if obvious fix, then **STOP and ask** 5. **Run Tests**: `dotnet test --no-build --nologo --verbosity minimal` 6. **If Tests Fail**: Extract failures with `rg`, fix if obvious, else **STOP and ask**

Two-Strike Rule

If build or test fails twice on the same issue: 1. **STOP** immediately 2. Present the error output 3. Show the code change made 4. Ask for user guidance

---

Step 1: Identify Project Type

echo "🔍 Detecting .NET project type..."

if [ -f "ProjectSettings/ProjectVersion.txt" ]; then
    echo "🎮 Unity project detected"
    PROJECT_TYPE="unity"
    cat ProjectSettings/ProjectVersion.txt
elif [ -f "*.sln" ] || [ -f "*.csproj" ]; then
    echo "📦 .NET solution/project detected"
    PROJECT_TYPE="dotnet"
else
    echo "❓ No .NET project found"
    exit 1
fi

---

Unity Test Framework

Run All Tests

echo "🧪 Running Unity tests..."

# Run all tests (Edit Mode + Play Mode)
unity-editor -runTests -batchmode -nographics \
    -projectPath . \
    -testResults TestResults.xml \
    -logFile test.log

# Check results
if [ $? -eq 0 ]; then
    echo "✅ All tests passed!"
else
    echo "❌ Some tests failed"
    # Parse results
    grep -E "Failed|Error" test.log | head -20
fi

Run Edit Mode Tests Only

echo "📝 Running Edit Mode tests..."

unity-editor -runTests -batchmode -nographics \
    -projectPath . \
    -testPlatform EditMode \
    -testResults EditModeResults.xml \
    -logFile editmode.log

if [ $? -eq 0 ]; then
    echo "✅ Edit Mode tests passed!"
else
    echo "❌ Edit Mode tests failed"
    grep -E "Failed|Error" editmode.log | head -20
fi

Run Play Mode Tests Only

echo "🎮 Running Play Mode tests..."

unity-editor -runTests -batchmode -nographics \
    -projectPath . \
    -testPlatform PlayMode \
    -testResults PlayModeResults.xml \
    -logFile playmode.log

if [ $? -eq 0 ]; then
    echo "✅ Play Mode tests passed!"
else
    echo "❌ Play Mode tests failed"
    grep -E "Failed|Error" playmode.log | head -20
fi

Run Specific Test Assembly

# Run tests from specific assembly
unity-editor -runTests -batchmode -nographics \
    -projectPath . \
    -testPlatform EditMode \
    -assemblyNames "MyGame.Tests" \
    -testResults Results.xml \
    -logFile test.log

Run Specific Test Class or Method

# Run specific test class
unity-editor -runTests -batchmode -nographics \
    -projectPath . \
    -testFilter "WalletServiceTest" \
    -testResults Results.xml \
    -logFile test.log

# Run specific test method
unity-editor -runTests -batchmode -nographics \
    -projectPath . \
    -testFilter "WalletServiceTest.Connect_WithValidCredentials_ReturnsTrue" \
    -testResults Results.xml \
    -logFile test.log

Parse Test Results

echo "📊 Parsing test results..."

if [ -f "TestResults.xml" ]; then
    # Count results
    TOTAL=$(grep -c "test-case" TestResults.xml || echo "0")
    PASSED=$(grep -c 'result="Passed"' TestResults.xml || echo "0")
    FAILED=$(grep -c 'result="Failed"' TestResults.xml || echo "0")

    echo "Total: $TOTAL | Passed: $PASSED | Failed: $FAILED"

    # Show failed tests
    if [ "$FAILED" -gt 0 ]; then
        echo ""
        echo "❌ Failed tests:"
        grep -B1 'result="Failed"' TestResults.xml | grep "name=" | head -10
    fi
fi

---

Standard .NET Testing

Run All Tests

echo "🧪 Running .NET tests..."

# Restore and build first
dotnet restore
dotnet build --no-restore --configuration Release

# Run tests
dotnet test --no-build --configuration Release \
    --logger "console;verbosity=normal" \
    --results-directory TestResults

if [ $? -eq 0 ]; then
    echo "✅ All tests passed!"
else
    echo "❌ Some tests failed"
fi

Run Tests with Coverage

Read more
Ships withsolana-ai-kit

Production-ready Claude Code configuration for full-stack Solana development. Combines best practices from multiple sources into an agent-optimized, token-efficient config you can install and adapt to your specific project.

Get the whole plugin

Other commands on solana-ai-kit.