Skip to content

Conversation

@skogseth
Copy link
Contributor

This adds support for using the #[test] attribute on functions with no parameters (previously these tests had to take the TestContext parameter as the only argument). So code like this should now work as expected:

#[libtest2::test]
fn simple_test() {
    assert_eq!(2 + 2, 4);
}

Other parameter combinations are not supported.

Part of #13.

@coveralls
Copy link

coveralls commented Dec 16, 2025

Pull Request Test Coverage Report for Build 20307320772

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 32.092%

Totals Coverage Status
Change from base Build 20304930312: 0.0%
Covered Lines: 543
Relevant Lines: 1692

💛 - Coveralls

Copy link
Collaborator

@epage epage left a comment

Choose a reason for hiding this comment

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

Let me know when you rebase since github doesn't always send notifications for rewrites of history

This supports using the `test` attribute on function with no parameters:
```
#[libtest2::test]
fn simple_test() {
	...
}
```
@skogseth skogseth force-pushed the empty-parameter-list branch from 39a8227 to c733043 Compare December 17, 2025 14:58
These tests aim to specifically test that the macros accept various
edge cases that a user might expect us to support. This includes:
- No parameters
- Return result (with and without context as a parameter)
- Include context as a parameter, but ignore it
- Include context as a parameter and pattern match on it
@skogseth skogseth force-pushed the empty-parameter-list branch from c733043 to 6bbfaf5 Compare December 17, 2025 15:04
@skogseth
Copy link
Contributor Author

@epage rebased

@epage epage merged commit 08e02cd into assert-rs:main Dec 17, 2025
15 checks passed
@epage
Copy link
Collaborator

epage commented Dec 17, 2025

Thanks!

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.

3 participants