Expand description
Testing utilities for plugin development.
This module provides two complementary approaches for testing plugins:
PluginTestRunner- A test runner with assertion methods and fixture-based testingTestCase- A builder for inline, declarative test assertions
§Quick Example
use nginx_lint_plugin::prelude::*;
use nginx_lint_plugin::testing::{PluginTestRunner, TestCase};
// Define a simple plugin for demonstration
// Use PluginTestRunner for quick assertions
let runner = PluginTestRunner::new(MyPlugin);
runner.assert_has_errors("http {\n bad_directive on;\n}");
runner.assert_no_errors("http {\n good_directive on;\n}");
// Use TestCase for declarative, detailed assertions
TestCase::new("http {\n bad_directive on;\n}")
.expect_error_count(1)
.expect_error_on_line(2)
.run(&MyPlugin);§Fixture Directory Structure
tests/fixtures/
└── 001_basic/
├── error/nginx.conf # Config that should trigger errors
└── expected/nginx.conf # Config after applying fixes (no errors expected)Structs§
- Plugin
Test Runner - Test runner for plugins.
- Test
Case - Declarative test builder for inline plugin tests.