-
Notifications
You must be signed in to change notification settings - Fork 106
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
An exception occurred while invoking executor 'executor://nunit3testexecutor/': Incorrect format for TestCaseFilter Error: Missing ')'. #622
Comments
Sorry for being late here. Question is if these characters should be filtered off, which is the safest way, I would assume. |
I am hanging this one onto this bug report since I think it would be in the same area. When you have a
This error only occurs when you try to perform a "Run all tests in Class" or "Run all tests". Repo Test:
|
I think @Dragonsangel is correct that tuples cause related issues, due to the parsing of the embedded parentheses. There likewise seem to be issues for any tuples passed in as test case data, due to their string representation always including parentheses. This code, which in the test runner would generate a name of TestA((1, 2), 5), does not run:
If the tuple is the final parameter as below, the test name is TestB(5, (1, 2)). This runs okay, perhaps because the generated test name has no further characters after the tuple's closing parenthesis.
One can also work around the problem by overriding the parameter names with
|
Using Visual Studio 2019 (v16.2.3) I'm unable to run any tests. I get the following error:
This happens every time, no matter how I select to run the tests (run all, run selected, etc...) |
As mentioned in #650, I tried downgrading (I uninstalled the VSIX adapter) and set my projects to use the 3.14 package. somehow, it still looks like it's choosing the wrong version (3.13 somehow?), but it's not working:
Any other ideas I can try to get my tests working? |
Looks like downgrading to VS 2017 (v15.9.15) lets me run my tests. Whatever issue I'm having is related specifically to how 2019 is calling the adapter it seems. Output using VS2017 (slightly truncated):
|
@johnjaylward Do you have any simple code that can repro this behaviour ? |
I'm using test cases sources that look similar to what's in #650 . [Test(), TestCaseSource(typeof(CaseTestData), nameof(CaseTestData.EqualsData))]
public void EqualsTest(Case case1, Case case2)
{
Assert.AreEqual(case1, case2);
} most of my tests in this project are very simple like that. |
On my side, I have the same issue (on VS2019 last update) by adding this testCase : |
@OsirisTerje , I think it may be due to me testing lamdba expressions on a custom Linq.IQueryProvider. Here's my test case data. I'm pretty sure it was working before I started testing my Linq items: using NUnit.Framework;
using REST.API.DAL;
using REST.API.Model;
using REST.API.Linq;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Linq;
using Moq;
namespace REST.API.Tests.Linq
{
public static class ExpressionTransatorTestData
{
public static IEnumerable<TestCaseData> TranslateData
{
get
{
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test"),
"approval=test"
);
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.AutoCreatedCase == false),
"auto_created_case=false"
);
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.AutoCreatedCase == true),
"auto_created_case=true"
);
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test" && c.AutoCreatedCase == false),
"approval=test^auto_created_case=false"
);
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test" || c.AutoCreatedCase == false),
"approval=test^ORauto_created_case=false"
);
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test" || c.AutoCreatedCase == true),
"approval=test^ORauto_created_case=true"
);
// Mon Jan 2 15:04:05 MST 2006
// yyyy-MM-dd HH:mm:ss
DateTimeOffset testDateTime = new DateTimeOffset(2006, 1, 2, 3, 4, 5, TimeSpan.FromHours(-7));
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test"
&& c.AutoCreatedCase
|| c.ActivityDue < testDateTime),
"approval=test^auto_created_case^ORactivity_due<2006-01-02+10%3A04%3A05"
);
// test using a "new DateTime" in the expression
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test"
&& c.AutoCreatedCase
|| c.ActivityDue < new DateTimeOffset(2006, 1, 2, 3, 4, 5, TimeSpan.FromHours(-7))),
"approval=test^auto_created_case^ORactivity_due<2006-01-02+10%3A04%3A05"
);
// test using a "new DateTime" in the expression
yield return new TestCaseData(
(Expression<Func<Case, bool>>)((Case c) => c.Approval == "test"
&& c.AutoCreatedCase
|| c.ActivityDue < new DateTimeOffset(2006, 1, 2, 3, 4, 5, TimeSpan.FromHours(-7))),
"approval=test^auto_created_case^ORactivity_due<2006-01-02+10%3A04%3A05"
);
var mockAPI = new Mock<IRestApi>();
mockAPI.Setup(r => r.CreateQuery(It.IsAny<Expression>())).Returns<Expression>((e) =>
{
return (IQueryable)Activator.CreateInstance(typeof(Query<>).MakeGenericType(e.Type), new object[] { mockAPI.Object, e });
});
mockAPI.Setup(r => r.CreateQuery<Case>(It.IsAny<Expression>())).Returns<Expression>((e) =>
{
return new Query<Case>(mockAPI.Object, e);
});
mockAPI.Setup(r => r.CreateQuery<Case>(It.IsAny<Expression<Func<Case,bool>>>())).Returns<Expression<Func<Case, bool>>>((e) =>
{
return new Query<Case>(mockAPI.Object, e);
});
Query<Case> query = new Query<Case>(mockAPI.Object);
yield return new TestCaseData(
query.Where(c => c.Approval == "test").Expression,
"approval=test"
);
// test ref-link converions
yield return new TestCaseData(
query.Where(c => c.Account == "86837a386f0331003b3c498f5d3ee4ca").Expression,
"account=86837a386f0331003b3c498f5d3ee4ca"
);
Guid boxeoGuid = Guid.ParseExact("86837a386f0331003b3c498f5d3ee4ca", "N");
yield return new TestCaseData(
query.Where(c => c.Account == boxeoGuid).Expression,
"account=86837a386f0331003b3c498f5d3ee4ca"
);
//Check order by
yield return new TestCaseData(
query.Where(c => c.Approval == "test").OrderBy(c => c.Number).Expression,
"approval=test^ORDERBYnumber"
);
yield return new TestCaseData(
query.Where(c => c.Approval == "test").OrderBy(c => c.Number).ThenByDescending(c => c.Category)
.Expression,
"approval=test^ORDERBYnumber^ORDERBYDESCcategory"
);
// check multiple where
yield return new TestCaseData(
query.Where(c => c.Approval == "test").Where(c => c.Number != "5").Expression,
"approval=test^number!=5"
);
// test dot walks
yield return new TestCaseData(
query.Where(c => (+c.Account).Name == "boxeo").Expression,
"account.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => ((Account)c.Account).Name == "boxeo").Expression,
"account.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => (+(+c.Account).ParentAccount).Name == "boxeo").Expression,
"account.account_parent.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => ((Account)((Account)c.Account).ParentAccount).Name == "boxeo").Expression,
"account.account_parent.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => (+((Account)c.Account).ParentAccount).Name == "boxeo").Expression,
"account.account_parent.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => ((Account)(+c.Account).ParentAccount).Name == "boxeo").Expression,
"account.account_parent.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => (+(+(+c.Account).ParentAccount).ParentAccount).Name == "boxeo").Expression,
"account.account_parent.account_parent.name=boxeo"
);
yield return new TestCaseData(
query.Where(c => (+(+(+c.Account).ParentAccount).ParentAccount).Name == "boxeo"
&& c.Active == true
|| c.State == CaseState.New
).Expression,
"account.account_parent.account_parent.name=boxeo^active=true^ORstate=1"
);
}
}
}
} |
@johnjaylward Can you upload this to a git repo somewhere, with the rest of the files, so it becomes a working compilable repro of this case ? |
Not readily, I have not been authorized by my company to release the source code. I'll see if I can make time to create a sample project that is slimmed down to just the ideas |
I'm pretty sure it's the same issue, or at least very similar, as the error I get is as follows:
It would be more helpful if the error message included the test name/ data that was causing the issue. |
@OsirisTerje , here is a sample solution that reproduces the issue I see. |
@OsirisTerje is there anything I can do to help with this issue? I'm happy to spend some time on it and submit a PR if you could give me a bit of guidance on where to focus. For a bit of reference, I have several tests that hit this issue, mostly due to mismatched For example: |
It seems like the adapter is not escaping special characters when creating a filter from the test names that VS passes in (which originated from these SetName calls). |
The second example line above is already escaped, and if I got it right, that one also fails. Or do you mean something else? |
@johnmwright It would be awesome if you could step in here, any contributions are really appreciated. That said, this issue might not be easy, since the exception comes from the testhost, which doesn't accept our test names. The crash happens here:
It is caused by the special characters that is included in the test names, and which is not accepted by the FQN "standard" as set by the Visual Studio test host. Escaping them should be a way out, but I am not sure. I think what is needed is to get more information on what works and what doesn't here. You can build your own debug package and enable breakpoints by turning on the symbol here (uncomment it):
You build the package on command line by: The generated package can then be found in the package folder. Line 15 in bddee2c
Add a number to the modifier below, like ="01", and later step this one up for each new build you need to do |
If there is an error about a mismatched |
@OsirisTerje good news! I was able to get some time this week to work on this and have a working solution. I need to clean it up a bit and run through some of the other cases reported above before filing a PR. Hoping to have something for you this weekend. Any requests/requirements you need from me in order to submit PRs? |
@johnmwright You should be good to go. Notes:
|
FYI: I have filed PR #668 for this issue. |
@johnjaylward Can you confirm your code works with the changes in PR #668 ? A dev package should appear within a few minutes now at https://www.myget.org/feed/nunit/package/nuget/NUnit3TestAdapter , version 3.16.0-dev-* |
So, It solves the issue with the test project I made, but not the main project with my actual code. I've pushed the changes up to my test repo to have the tests pass instead of fail, and also updated to use the dev version of the test adapter. This change definitely solved some of the problems though. I'll need to figure out what's causing the issue in my main project. It seems to be separate from the naming that got fixed there. |
@OsirisTerje I'm going to open a new ticket for the new behavior I'm seeing. |
@johnjaylward Thanks, that's the best way to handle it too :-) If this is something with the adapter, it would be good to have it in. I would like to see whatever that is before we do a new release. |
Dev package resolving this is at https://www.myget.org/feed/nunit/package/nuget/NUnit3TestAdapter/3.16.0-dev-01202 |
As an update to this, I tested the fix with the 3.16.0-dev-01202 package and this Test is not run with the same error message as described in this issue.
If I however switch around the Types, then it will execute Summary: |
Happened to me on VS2022. Fixed it by removing the "{m}" modifier inside of the property TestName. |
Occurring for me on VS2022, but not VS2019. The project will throw the "missing (" exception when a test group is started from Test Explorer in VS2022, but opening the same project in VS2019 and running the same test group will succeed. |
ENVIRONMENT
NUnit: 3.10.1
NUnit3TestAdapter: 3.10.0
Visual Studio: 15.9.2
.NET Platform: .NET Core 2.1
DESCRIPTION
When executing a category of tests, if a test is included in the list of tests that contains an opening parenthesis, but does not contain the closing parenthesis, the following error may occur, and the test run will fail:
REPRODUCTION
This issue can only be reproduced when selecting a group of tests to run - selecting individual tests, or selecting 'Run All' will no reproduce the issue.
It appears that reproducing the issue requires there to be a test that includes an opening parenthesis but does not include a closing parenthesis, and a test that ends with the closing bracket character (']').
You should be able to reproduce the issue by using the following test code:
Once built, categorize the test explorer using the 'Class' category selection, and select the test suite 'TestNameRepro' and click 'Run Selected Tests':
![image](https://user-images.githubusercontent.com/11689280/55029292-209dec80-4fe0-11e9-8445-b61e44c8c232.png)
The 'Tests' output window should display the error mentioned above:
The text was updated successfully, but these errors were encountered: