Skip to content

NH-3905 - Missings async tests #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 6, 2017

Conversation

fredericDelaporte
Copy link
Member

NH-3905 - Due to various reasons, a bunch of tests were not having their async counterparts generated.

@@ -156,8 +156,6 @@
applyChanges: true
analyzation:
methodConversion:
- conversion: Ignore
hasAttributeName: IgnoreAttribute
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

See review.

@@ -7,5 +7,5 @@
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.3.6" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.4.0" targetFramework="net461" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Required for newly generated tests, due to #41, #43, #44 & #45.

@@ -156,8 +156,6 @@
applyChanges: true
analyzation:
methodConversion:
- conversion: Ignore
hasAttributeName: IgnoreAttribute
Copy link
Member Author

@fredericDelaporte fredericDelaporte Sep 5, 2017

Choose a reason for hiding this comment

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

This rule was causing tests from a base class overridden for marking them as NUnit [Ignored] to have their override ignored by async generator, thus having their async counterpart NUnit executed instead of being ignored.

Example of such a case in this fixture.

Copy link
Member

Choose a reason for hiding this comment

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

Ok

@@ -180,6 +178,8 @@
hasAttributeName: IgnoreAttribute
- conversion: NewType
hasAttributeName: TestFixtureAttribute
- conversion: NewType
anyBaseTypeRule: HasTestFixtureAttribute
Copy link
Member Author

Choose a reason for hiding this comment

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

Required for generating child classes of a base fixture if they are not themselves marked with the [Fixture] attribute.

@@ -8,6 +8,7 @@

namespace NHibernate.Test.Events.Collections
{
[TestFixture]
public abstract class AbstractCollectionEventFixture : TestCase
Copy link
Member Author

Choose a reason for hiding this comment

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

With current generation rules, it is required to flag a base class with [TextFixture] if it defines tests potentially needing an async counterpart.

@@ -5,6 +5,7 @@

namespace NHibernate.Test.CfgTest
{
[TestFixture]
public class AccessorsSerializableTest
Copy link
Member Author

@fredericDelaporte fredericDelaporte Sep 5, 2017

Choose a reason for hiding this comment

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

Async counterparts are currently generated only for classes marked with TestFixture. Lacking it causes the fixture to be ignored. I have added the attribute on all fixture defining tests and lacking it.

Since this attribute is no more needed by NUnit, we are effectively using it as a kind of GenerateAsync attribute...

We could add our own specific attribute for that and replace all TextFixture by it. It would be more explicit.

@@ -158,6 +160,15 @@ public override void OnInitializeCollection(InitializeCollectionEvent @event)
base.OnInitializeCollection(@event);
AddEvent(@event, this);
}

public override Task OnInitializeCollectionAsync(InitializeCollectionEvent @event, CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

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

Async generator does not currently generates async counterparts for overrides of synchronous methods. See #46. Some other test classes are affected and fixed too.

return result;
}

public override Task<DbCommand> PrepareBatchCommandAsync(CommandType type, SqlString sql, SqlType[] parameterTypes, CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

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

Bunch of missing async override counterparts here too.

// the list contains at least one Cat then should Throws
Assert.That(() => query.ToList(), Throws.Exception);
// Do not use bare Throws.Exception due to https://github.com/nunit/nunit/issues/1899
Assert.That(() => list = query.ToList(), Throws.InstanceOf<GenericADOException>());
Copy link
Member Author

@fredericDelaporte fredericDelaporte Sep 5, 2017

Choose a reason for hiding this comment

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

Two bugs in one. #47, worked around by adding the local variable and #1899, worked around by using InstanceOf. The later was causing three other tests to fail, they have been "worked around" too.

@@ -104,6 +107,12 @@ public override DbDataReader ExecuteReader(DbCommand cmd)
LastCommandTimeout = cmd.CommandTimeout;
return base.ExecuteReader(cmd);
}

public override Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

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

Again, missing async counterpart otherwise.

@fredericDelaporte fredericDelaporte merged commit 5d8219b into nhibernate:master Sep 6, 2017
@fredericDelaporte fredericDelaporte deleted the NH-3905 branch September 6, 2017 09:56
@fredericDelaporte fredericDelaporte added this to the 5.0 milestone Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants