You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2022/11/03 10:31:52 UTC
[GitHub] [lucenenet] NightOwl888 opened a new issue, #739: [Slow] attribute runs the code in BeforeClass() and AfterClass() even when the `tests:slow` property is set to `false`
NightOwl888 opened a new issue, #739:
URL: https://github.com/apache/lucenenet/issues/739
When the `SlowAttribute` in `Lucene.Net.TestFramework` is placed on a `LuceneTestCase`-derived class, it runs the code in the `BeforeClass()` and `AfterClass()` methods (which are decorated with `[OneTimeSetUp]` and `[OneTimeTearDown]`) even when the system property `tests:slow` is set to `false`. This causes these disabled tests to run code, taking up extra testing time. Since the purpose of these settings is to optimize the test run, this undesired behavior is a bug.
I suspect (but haven't confirmed) that the following other attributes also have a similar issue, since they all follow the same basic design.
- `AwaitsFixAttribute`
- `NightlyAttribute`
- `WeeklyAttribute`
Ideally, these would completely suppress any actions from occurring when applied at the class level when their associated [system property](https://github.com/apache/lucenenet/issues/307) is disabled. System properties are statically loaded by the test framework in [LuceneTestCase](https://github.com/apache/lucenenet/blob/c076e40b14d4c20e6fdfee4e28d0b3332cf6d0ce/.github/workflows/Lucene-Net-Tests-AllProjects.yml#L130).
> Note: There is some better info [here](https://lucenenet.apache.org/docs/4.8.0-beta00016/api/test-framework/Lucene.Net.Util.LuceneTestCase.html#randomized-execution-and-test-facilities) on how to specify system properties and command line example [here](https://github.com/apache/lucenenet/blob/c076e40b14d4c20e6fdfee4e28d0b3332cf6d0ce/.github/workflows/Lucene-Net-Tests-AllProjects.yml#L130). No general docs for this yet.
These attributes use NUnit's extensibility through attribute interfaces `IApplyToTest`, `IApplyToContext`, and `IWrapTestMethod` to function. NUnit scans for attributes that implement these interfaces in order to execute them.
Ideally, we find a way to suppress the `[OneTimeSetUp]` and `[OneTimeTearDown]` calls somehow. But these execution calls are owned by NUnit.
Failing that we may be able implement our own attributes with the same names that implement the same interfaces. When these attributes are placed as nested classes of `LuceneTestCase`, they effectively "override" the attributes in the `NUnit.Framework` namespace for `LuceneTestCase` or any class that inherits it.
> Note: We use this approach already for our custom [`[TestFixtureAttribute]`](https://github.com/apache/lucenenet/blob/c076e40b14d4c20e6fdfee4e28d0b3332cf6d0ce/src/Lucene.Net.TestFramework/Support/Util/LuceneTestCase.TestFixtureAttribute.cs#L41). There may be some way to use that custom attribute to fix this where we have direct control over the code. It looks like we are already intercepting these calls [here](https://github.com/apache/lucenenet/blob/c076e40b14d4c20e6fdfee4e28d0b3332cf6d0ce/src/Lucene.Net.TestFramework/Support/Util/LuceneTestCase.SetUpFixture.cs#L70-L92), but I am not sure whether that gives us ownership over all of them.
There is some [custom attribute documentation](https://docs.nunit.org/articles/nunit/extending-nunit/Custom-Attributes.html), but it doesn't actually include `IWrapTestMethod` or [other interfaces that are available in the source code](https://github.com/nunit/nunit/tree/b16d7540ea424d147847ce7af2a576e98a411209/src/NUnitFramework/framework/Interfaces).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Slow] attribute runs the code in BeforeClass() and AfterClass() even when the `tests:slow` property is set to `false` [lucenenet]
Posted by "NightOwl888 (via GitHub) via dev" <de...@lucenenet.apache.org>.
NightOwl888 closed issue #739: [Slow] attribute runs the code in BeforeClass() and AfterClass() even when the `tests:slow` property is set to `false`
URL: https://github.com/apache/lucenenet/issues/739
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Slow] attribute runs the code in BeforeClass() and AfterClass() even when the `tests:slow` property is set to `false` [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on issue #739:
URL: https://github.com/apache/lucenenet/issues/739#issuecomment-6272725831
Marking this as blocked by #1087 because changes in PR #1427 would likely conflict. #1427 should land first before we take this on.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Slow] attribute runs the code in BeforeClass() and AfterClass() even when the `tests:slow` property is set to `false` [lucenenet]
Posted by "NehanPathan (via GitHub) via dev" <de...@lucenenet.apache.org>.
NehanPathan commented on issue #739:
URL: https://github.com/apache/lucenenet/issues/739#issuecomment-7058806565
I investigated this behavior and was able to reproduce it.
When running with `tests:slow=false`, a fixture marked `[Slow]` still executes its one-time setup and teardown. In my reproduction, the counters were `(1, 1)` instead of the expected `(0, 0)`.
I observed the same behavior with class-level `[Nightly]`, `[Weekly]`, and `[AwaitsFix]` attributes when their respective filters were disabled.
Although the tests are marked as skipped during filtering, the fixture lifecycle still appears to execute, allowing `OneTimeSetUp` and `OneTimeTearDown` to run.
It would be worth adding regression tests to verify that disabled fixtures do not execute setup or teardown side effects, covering these attributes as well as mixed enabled/disabled scenarios.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org