Skip to content

Comments

test: add anti-pattern checks for structural vs behavioral tests #507#510

Draft
Serhan-Asad wants to merge 1 commit intopromptdriven:mainfrom
Serhan-Asad:test/issue-507
Draft

test: add anti-pattern checks for structural vs behavioral tests #507#510
Serhan-Asad wants to merge 1 commit intopromptdriven:mainfrom
Serhan-Asad:test/issue-507

Conversation

@Serhan-Asad
Copy link
Collaborator

Summary

Adds tests verifying that the Step 7 prompt contains proper guidance against generating structural tests (e.g., inspect.signature checks) instead of behavioral tests.

Test Files

  • tests/test_agentic_bug_step7_prompt.py

Test Coverage

  • Total Tests: 21 (4 new + 17 existing)
  • Framework: pytest
  • Status: All passing

What These Tests Verify

  • Anti-pattern warnings against structural signature checks exist in the prompt
  • Behavioral testing guidance is present
  • The prompt discourages inspect.signature / sig.parameters patterns
  • Positive examples of mock-based behavioral tests are referenced

Test Execution

pytest tests/test_agentic_bug_step7_prompt.py -v

Next Steps

  1. Review the generated tests
  2. Run tests locally to verify
  3. Adjust tests if needed
  4. Mark PR as ready for review

Closes #507


Generated by PDD agentic test workflow

…tdriven#507

Add tests verifying that the Step 7 prompt contains guidance against
generating structural tests (inspect.signature checks) instead of
behavioral tests that verify actual functionality.

Closes promptdriven#507

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive test coverage for verifying that the Step 7 prompt properly guides against generating structural tests (like inspect.signature checks) and instead promotes behavioral testing approaches.

Changes:

  • Added new test class TestStep7PromptStructuralTestAntiPattern with 6 test methods
  • Tests verify anti-pattern warnings, behavioral testing guidance, and mock-based verification examples in the Step 7 prompt

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +221 to +229
has_warning = any([
"inspect.signature" in content_lower,
"sig.parameters" in content_lower,
# The prompt warns against testing signatures via the anti-pattern section
"anti-pattern" in content_lower and "signature" in content_lower,
# General guidance against non-behavioral testing
"testing behavior, not implementation" in content_lower,
"behavior, not implementation details" in content_lower,
])
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The variable name has_warning is misleading since the conditions also check for general behavioral testing guidance (lines 227-228) which aren't warnings. Consider renaming to has_structural_test_guidance or similar to better reflect that it checks for either warnings OR guidance.

Copilot uses AI. Check for mistakes.
Comment on lines +238 to +248
has_warning = any([
"parameter existence" in content_lower,
"parameter accepts" in content_lower,
"function accepts" in content_lower and "parameter" in content_lower,
"signature check" in content_lower,
"structural" in content_lower and "test" in content_lower,
# The prompt has an anti-pattern section warning against testing callee's signature
"anti-pattern" in content_lower and "callee" in content_lower,
# Testing the signature vs testing behavior
"callee's signature" in content_lower or "callee rejects" in content_lower,
])
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The variable name has_warning is reused with a different meaning than in the previous test method. Consider using a more specific name like has_parameter_check_warning to improve code clarity and avoid confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +293 to +295
has_anti_pattern_example = any([
"inspect.signature" in content_lower and ("wrong" in content_lower or "anti" in content_lower or "do not" in content_lower or "don't" in content_lower),
"sig.parameters" in content_lower and ("wrong" in content_lower or "anti" in content_lower or "do not" in content_lower or "don't" in content_lower),
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

These two lines have duplicated logic with repeated condition checks. Consider extracting the repeated tuple ("wrong" in content_lower or "anti" in content_lower or "do not" in content_lower or "don't" in content_lower) into a variable to reduce duplication and improve readability.

Suggested change
has_anti_pattern_example = any([
"inspect.signature" in content_lower and ("wrong" in content_lower or "anti" in content_lower or "do not" in content_lower or "don't" in content_lower),
"sig.parameters" in content_lower and ("wrong" in content_lower or "anti" in content_lower or "do not" in content_lower or "don't" in content_lower),
has_warning_keywords = (
"wrong" in content_lower
or "anti" in content_lower
or "do not" in content_lower
or "don't" in content_lower
)
has_anti_pattern_example = any([
"inspect.signature" in content_lower and has_warning_keywords,
"sig.parameters" in content_lower and has_warning_keywords,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pdd bug generates structural tests (param existence checks) instead of behavioral tests

1 participant