Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element in unit tests left pending after completion

I'm seeing this warnings in Resharper after running tests, all the tests pass.

2018.08.09 11:11:58.524 WARN Element Data.Tests.Infra.IntegrationTests.ResolvedIdentityTests was left pending after its run completion. 2018.08.09 11:11:58.524 WARN Element Data.Tests.Infra.IntegrationTests.ResolvedIdentityTests.Reso was left pending after its run completion.

They are integration tests that setup some sql in a test database, then tests are run against that database.

Here is the full test class:

namespace Data.Tests.Infra.IntegrationTests
{
    using System;
    using System.Data.SqlClient;
    using System.Threading.Tasks;
    using Dapper;
    using Infrastructure.Models;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public sealed class ResolvedIdentityTests
    {
        [ClassInitialize]
        public static void Initialise(TestContext context)
        {
            const string sql = @"insert into infra.tblUnresolvedIdentities
                                (DeviceId, Fqdn, TimeConflictOccured)
                                values
                                ('85E33FB5-C321-4EF2-994C-C835F136BA0C', 'unr.test.foo', '2018-08-06 12:16:24.183'),
                                ('D3F32F97-2375-47CC-86E7-37C50ABAC85F', 'unr2.test.foo', '2018-08-06 12:16:24.183')

                                insert into infra.tblOrg ([Name]) values ('rito')
                                declare @orgId int = (select OrgId from infra.tblOrg where [Name] = 'rito');

                                insert into infra.tblSite ([SiteName], [OrgId]) values ('rito.site', @OrgId);
                                declare @siteId int = (select SiteId from infra.tblSite where [SiteName] = 'rito.site');

                                insert into infra.tblDevice
                                (DeviceId, [Name], SiteId)
                                values
                                ('CE810507-C614-4C65-9675-569EEFFDBC9F', 'unr.test.foo', @siteId),
                                ('94FF1C23-0B7E-41CB-A0F8-058CED0465B3', 'blacklisted.test.foo', @siteId)

                                insert into infra.tblBlacklistedAgents
                                (DeviceId, Fqdn)
                                values
                                ('94FF1C23-0B7E-41CB-A0F8-058CED0465B3', 'rit.test.com')";
            RunSql(sql);
        }

        [ClassCleanup]
        public static void Cleanup()
        {
            const string sql = @"delete from infra.tblBlacklistedAgents where DeviceId = '94FF1C23-0B7E-41CB-A0F8-058CED0465B3'
                                 delete from infra.tblUnresolvedIdentities where DeviceId in ('85E33FB5-C321-4EF2-994C-C835F136BA0C', 'D3F32F97-2375-47CC-86E7-37C50ABAC85F')
                                 delete from infra.tblDevice where DeviceID in( 'CE810507-C614-4C65-9675-569EEFFDBC9F', '94FF1C23-0B7E-41CB-A0F8-058CED0465B3')
                                 delete from infra.tblsite where SiteName = 'rito.site'
                                 delete from infra.tblorg where Name = 'rito'
                                 delete from infra.tblResolvedIdentities where ActualDeviceId = 'CE810507-C614-4C65-9675-569EEFFDBC9F'";
            RunSql(sql);
        }

        private static void RunSql(string sql)
        {
            using (var sqlConnection = new SqlConnection(Configuration.InitConfiguration()["ConnectionString"]))
                sqlConnection.Execute(sql);
        }

        [TestMethod]
        public async Task ResolvedIdentityTests_ShouldResolveAnIdentityAndAddRowToResolvedIdentityTable()
        {
            var infra = new Infrastructure.Identities(Configuration.InitConfiguration()["ConnectionString"]);
            await infra.ResolveIdentity(erroneousDeviceId: new Guid("85E33FB5-C321-4EF2-994C-C835F136BA0C"), actualDeviceId: new Guid("CE810507-C614-4C65-9675-569EEFFDBC9F"));

            // now call GetResolvedIdentity so we can verify it was resolved.
            var resolvedIdentity = await infra.GetResolvedIdentity(new Guid("85E33FB5-C321-4EF2-994C-C835F136BA0C"));
            Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity.ActualDeviceId, expected: new Guid("CE810507-C614-4C65-9675-569EEFFDBC9F"));
            Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity.SiteName, expected: "rito.site");
            Assert.IsFalse(resolvedIdentity.ResolvedIdentity.Id == -1);
            Assert.AreEqual(actual: resolvedIdentity.ResolutionStatus, expected: IdentityResolutionState.Resolved);
        }

        [TestMethod]
        public async Task GetResolvedIdenity_ShouldResolveToBlacklisted()
        {
            var infra = new Infrastructure.Identities(Configuration.InitConfiguration()["ConnectionString"]);
            var resolvedIdentity = await infra.GetResolvedIdentity(new Guid("94FF1C23-0B7E-41CB-A0F8-058CED0465B3"));

            Assert.AreEqual(actual: resolvedIdentity.ResolutionStatus, expected: IdentityResolutionState.Blacklisted);
            Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity, expected: null);
        }

        [TestMethod]
        public async Task GetResolvedIdenity_ShouldResolveToStillPending()
        {
            var infra = new Infrastructure.Identities(Configuration.InitConfiguration()["ConnectionString"]);
            var resolvedIdentity = await infra.GetResolvedIdentity(new Guid("D3F32F97-2375-47CC-86E7-37C50ABAC85F"));

            Assert.AreEqual(actual: resolvedIdentity.ResolutionStatus, expected: IdentityResolutionState.Pending);
            Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity, expected: null);
        }
    }
}

I have no idea why any of these tests will still be pending, or if the warnings are even something I should care about.

This is in the Resharper test runner, no warnings are shown when running in MS test runner (but maybe it doesn't display warnings?)

like image 682
Stuart Avatar asked Aug 09 '18 10:08

Stuart


2 Answers

It looks like a bug in ReSharper:

https://resharper-support.jetbrains.com/hc/en-us/community/posts/360000057490-Unit-Test-Sessions-reports-Inconclusive-Test-not-run-

https://youtrack.jetbrains.com/issue/RSRP-469301

like image 139
EM0 Avatar answered Sep 29 '22 21:09

EM0


Changing my Solution Platform to x64 from any CPU solved this issue for me.

like image 20
William Avatar answered Sep 29 '22 22:09

William