Skip to content

Every test asserts something - #70

Merged
jbtule merged 1 commit into
masterfrom
assert-everything
Sep 22, 2026
Merged

jbtule merged 1 commit into
masterfrom
assert-everything

Conversation

@jbtule

@jbtule jbtule commented Sep 22, 2026

Copy link
Copy Markdown
Member

Closes #69.

Fifteen tests reported NoError rather than Success — they passed without asserting anything. The count is now 0, and no test was deleted to get there.

Most of them were making a real claim invisibly, so each now states it:

tests was now asserts
MimicTest ×9 dynamic result = mimic.A.B.C; members, calls, indexes and operators each yield another Mimic; a conversion yields the target type's default value
GetterVoidTest, ForwardVoidTest tTest.Action(); VoidMethodPoco records that it ran, so the call is proven to have reached the target
TestInvokeAddDynamic, TestInvokeSubtractDynamic invoke and hope Moq verifies TryBinaryOperation was reached — the thing being tested
GenericStructInNullableContextTest build a proxy the proxy builds and works
Set_Index assignment with no value to inspect explicit Assert.DoesNotThrow

The Mimic ones are the clearest gain: the old versions would not have noticed a Mimic that started returning null instead of another Mimic, because not throwing was the whole test.

PrintOutInterface was not a test. It printed a generated ILinq<T> declaration to the console and could not fail. Rather than delete it, it now asserts that the generation still produces the members ILinq<T> was authored from — an empty or shapeless run means the reflection stopped matching, which is worth knowing when a new .NET version reshapes Enumerable.

One fixture change, additive: VoidMethodPoco gains a Ran property.

Verified: 190 on net8.0 and net10.0, 196 on net47, 101 on browser-wasm, NoError count 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_016mwfq4oeZW8SiD4HjTHYdg

…nothing throws (#69)

Fifteen tests reported NoError rather than Success - they passed without
asserting. Most were making a real claim invisibly, so each now says it:

- The MimicTest set: a Mimic's members, calls, indexes and operators all
  yield another Mimic, and a conversion yields the target type's
  default-constructed value. Asserting that would have caught a Mimic
  that started returning null, which "does not throw" would not.
- The two void tests: VoidMethodPoco records that it ran, so the test
  asserts the call reached the target rather than merely that the dynamic
  invocation survived.
- The two mock operator tests: Moq verifies TryBinaryOperation was
  actually reached, which is the thing being tested.
- GenericStructInNullableContextTest: the proxy builds *and* works.
- Set_Index, where there is no value to inspect, is an explicit
  Assert.DoesNotThrow.

PrintOutInterface was not a test at all - it printed a generated ILinq<T>
to the console and could not fail. The members it generates are how that
interface was authored, so it now asserts the generation still produces
them; an empty or shapeless run means the reflection stopped matching.

190 on net8.0 and net10.0, 196 on net47, 101 on wasm, and the NoError
count is 0.

Closes #69.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016mwfq4oeZW8SiD4HjTHYdg
Copilot AI lite review requested due to automatic review settings September 22, 2026 18:45
@jbtule
jbtule merged commit 51e9d3b into master Sep 22, 2026
15 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved findings remain in generated-member matching and Mimic operator coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

This PR adds explicit assertions to previously assertion-free tests, improving test-result reliability.

Changes:

  • Verifies Mimic operations, conversions, proxy behavior, and void dispatch.
  • Validates dynamic binary-operation dispatch and generated LINQ members.
  • Adds tracking support for confirming void calls execute.
File Reviewed changes
Tests/​UnitTestImpromptuInterface/​Support/​SupportDefinitions.cs Adds void-call tracking support.
Tests/​UnitTestImpromptuInterface/​SingleMethodInvoke.cs Verifies binary-operation dispatch.
Tests/​UnitTestImpromptuInterface/​MimicTest.cs Adds Mimic behavior and conversion assertions.
Tests/​UnitTestImpromptuInterface/​Linq.cs Checks generated LINQ members.
Tests/​UnitTestImpromptuInterface/​ImpromptuDynamic.cs Confirms void calls reach their targets.
Tests/​UnitTestImpromptuInterface/​Basic.cs Verifies generic-struct proxy behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +144 to +153
var generated = tList
.Where(it => it.GetParameters().Any()
&& (HelperIsGenericExtension(it, typeof(IEnumerable<>))
|| it.GetParameters().First().ParameterType == typeof(IEnumerable)))
.Select(HelperMakeName)
.ToList();

Assert.IsNotEmpty(generated);
foreach (var expected in new[] { "Where", "Select", "First" })
Assert.IsTrue(generated.Any(it => it.Contains(expected)), "generated ILinq<T> declares " + expected);
result = mimic |= true;
result = mimic &= false;
result = mimic %= 5;
Assert.IsInstanceOf<Mimic>(result); // an operator on a Mimic is a Mimic
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.

15 tests assert nothing; make the intent explicit (or delete the ones that have none)

2 participants