Skip to content
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

Merge UpCodes improvements #87

Merged
merged 39 commits into from Mar 22, 2019
Merged

Conversation

marchello2000
Copy link
Contributor

The following improvements have been made, we'd like to merge them back into the main repo.

  • Nuget package has been created
  • AppVeyor build has been configured
  • groupByModel parameter (see below) has been added
  • Numerous UI improvements, such as
    • Better error messaging when test model isn't found
    • Auto expand failing tests
    • Summarize how many tests passed/failed/etc
    • Show tests without a category
    • Ability to clear console output
    • Clear indication when model files for tests can't be found
  • Ability to specify a wildcard for the model filename
  • All console messages are marshaled back from the test and displayed by the runner
  • Test completion information is displayed in the console out as soon as the test itself is completed

I am happy to work with you to transfer ownership of the nuget package/appveyor build

Mark Vulfson and others added 30 commits May 16, 2018 11:01
* Tests in same fixture with same model path will run with the same model (without reopening the model)
* Additional fixes:
    - Remember the directory for file pickers
    - Automatically set the working/results directory
    - Automatically infer the version of Revit to use from the assembly (based on the RevitAPI linked against)
    - Clean up a bunch of stale variables, update parts to modern C# standards
    - Fix by category grouping to show tests that aren't in a category
Group tests by model with the `GroupByModel` param
Fix the test runner such that it spits out an error when a text model…
* Show how many tests pass/fail after a test run
* Auto expand tree with failing tests
* Add `ERROR` and `WARNING` to appropriate WriteLines to clearly highlight when
  something goes wrong
* Compact the UI a bit and give more room to console logger
* Clearly state how many tests pass/fail/skip in the last run in the console log for the gui
Properly fail tests whose model isn't found
The way it's implemented is as follows:
1. During assembly load, check if a test has a wildcard for the model, e.g.
```
[TestModel(@"C:\RevitModels\test_models\*.rvt")]
```
or
```
[TestModel(@"C:\RevitModels\test_models\*.rfa")]
```

2. Enumerate all files that match the wildcard in the specified directory
3. For each model file found, create a separate entry for the current test with this model
Add ability to specify wildcard for a model file name
Add error when no model files are found with a given wildcard
In case Revit doesn't terminate within a timeframe (45s) it is force terminated
after test run is complete (only works for -continuous right now)
Add a timeout to Revit termination
* Use Nugets for Revit dependencies (e.g. RevitAPI.dll and RevitAddingUtility.dll)
* Remove platform architecture warnings
* Remove some unused variables and other warnings from build
* Remove double definition of NUnitResultTypes
* Add ability to override Revit installation enumeration during UnitTests for CI machines with Revit
* Update Nuget package and add AppVeyor.yaml file
Automated build with AppVeyor

* Use Nugets for Revit dependencies (e.g. RevitAPI.dll and RevitAddingUtility.dll)
* Remove platform architecture warnings
* Remove some unused variables and other warnings from build
* Remove double definition of NUnitResultTypes
* Add ability to override Revit installation enumeration during UnitTests for CI machines with Revit
* Update Nuget package and add AppVeyor.yaml file
void OnErrorOutLine(string text);
}

public class ConsoleOutInterceptor : IDisposable
Copy link
Member

Choose a reason for hiding this comment

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

can you add summary tags for this public class and public methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<Reference Include="RevitAPI">
<HintPath>$(REVITAPI)\RevitAPI.dll</HintPath>
<Reference Include="RevitAPI, Version=17.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\RevitAPI.dll</HintPath>
Copy link
Member

Choose a reason for hiding this comment

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

where is this nuget package from? Is this an official Autodesk distribution? Kind of odd that this is a 2019 branch of RTF but this is using a 2017 package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish there was an official Autodesk channel, but I haven't seen any. Perhaps you know?
I think the whole 2017 vs 2019 branch is a bit weird as I don't see much changes Revit wise (but I also haven't deeply inspected the diff). This version of RTF works fine for 2017, 2018, and 2019.
There aren't any API's that RTF uses that are not present in 2018/2019, so I picked 2017 to cover the most versions for users. And Revit seems to happily rebind to the current version of RevitAPI.dll et.al. during its assembly resolution (which is nice)
But yes, strange. I can add a comment to the csproj
Btw, the reason I need this is to enable appeveyor CI build

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @marchello2000 I'm really sorry for no reply after such a long time. But I think it's better to use $(REVITAPI) path here, the package you use from nuget website may be a little risky. If you don't want to use the installed Revit, you can add a extern folder to $(REVITAPI) like
$(SolutionDir)..\lib\Revit $(RevitVersionNumber)\net47.
When CI build, you can download the RevitAPI you want to use and place them in this folder.
If you have no time for this, I would help you merge this PR and fix this problem later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ZiyunShang Thanks for merging, the PR. I see you already merged the PR for $(REVITAPI) change, let me comment on there as I think it's more relevant

}

/// <summary>
/// Sends a message with a line of console text that the text produces
Copy link
Member

Choose a reason for hiding this comment

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

I have read this 3 times and am still confused 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha, sorry, yeah, this is not comprehensible - let me fix that!

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Revit-2017.1.1-x64.Base" version="2.0.0" targetFramework="net47" />
Copy link
Member

Choose a reason for hiding this comment

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

same question as above regarding this package.

private bool workingDirSetByUser = false;
private bool resultsFileSetByUser = false;

int passedTestCount;
Copy link
Member

Choose a reason for hiding this comment

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

access modifier please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thank you!

}
}

public int PassedTestCount
Copy link
Member

Choose a reason for hiding this comment

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

please add summaries for the public properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

}
}

public bool GroupByModel
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍


tr = new TextRange(textBox.Document.ContentEnd, textBox.Document.ContentEnd);
tr.Text = line;
if (line.ToLower().Contains("error:"))
Copy link
Member

Choose a reason for hiding this comment

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

a small thing - would be nice if these could be referred to throughout the code using an enum or const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, thanks! will add consts

/// <summary>
/// Version of Revit referenced by the assembly
/// </summary>
public string ReferencedRevitVersion { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

interesting - do you have a use case for this yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is used in the GUI to automatically select the "most appropriate" Revit version installed - a small convenience

@@ -87,76 +97,128 @@ public static bool ReadFixture(Type fixtureType, IAssemblyData data, string work
public static bool ReadTest(MethodInfo test, IFixtureData data, string workingDirectory)
{
//set the default modelPath to the empty.rfa file that will live in the build directory
Copy link
Member

Choose a reason for hiding this comment

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

is this comment still valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, gotta move it, thanks!


namespace RTF.Framework
{
[Serializable]
public class AssemblyData : IAssemblyData
{
private bool? _shouldRun = true;
private ObservableCollection<ITestGroup> _sortingGroup;
private bool _isNodeExpanded;
Copy link
Member

Choose a reason for hiding this comment

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

style thing - I think in new .net code we prefer to not use _ notation for fields - generally we just name the field camelCase and the property PascalCase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with that, was just trying to follow "when in Rome" rule for consistency. But I am happy to fixup the whole file if you prefer. Let me know

}
catch
{
// Nothing to do, just say the model isn't there (probably a wildcard in the file name
Copy link
Member

Choose a reason for hiding this comment

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

should this be logging something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, this is used by the UI to highlight tests that have a missing model, so there is a feedback loop there already. the reason I had to change it was because the path now can be a wildcard which File.Exists doesn't like

@@ -199,7 +200,7 @@ public interface IRunner
/// <summary>
/// Setup tests. Precedes a call to RunAllTests.
Copy link
Member

Choose a reason for hiding this comment

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

now that this returns a bool can you update this summary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

<tags>revit, autodesk, revit test framework</tags>
</metadata>
<files>
<file src="..\bin\AnyCPU\Release\Microsoft.Practices.Prism.dll" target="tools" />
Copy link
Member

Choose a reason for hiding this comment

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

⚠️
I do not think we should be distributing these dlls directly in this package. They have license terms that users must agree to outside of usage here - instead shouldn't this package have dependencies on those packages like nunit, prism etc...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with this 100%. The problem is that it's quite a big refactor to make RTF use all the libraries that are currently committed to the repo as nugets. I am happy to try to tackle this after this PR goes in, but I would say outside the scope of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mjkkirschner I have addressed this by using Fody.Costura and merging the needed bits into the resultant RTF assembly. This way, these files (prism, nunit, etc) don't have to be distributed with this nuget.

@mjkkirschner
Copy link
Member

@marchello2000 - Thanks for this work, lots of good improvements. I have a few comments, most are not that important but I think a few require changes before this can be merged.

Also - It appears to me there are a lot of new features here but no new tests? Not that RTF was particularly well tested itself (AFAIK) but if possible we should grow the tests to cover the new features.

@marchello2000
Copy link
Contributor Author

@mjkkirschner : thank you very much for review - I know it was a bunch of code!
I am going through comments and making changes. Will push an update in a the next day or two, time permitting.

I spend a heck of a time even understanding how to get the tests to run (since RTF doesn't use standard nunit nuget). I do have it running now. I will try to add some more tests - the problem is that the surface I changed wasn't really tested before at all, so it will probably require a few new mocks - I shall look into this.

Thanks again, updates coming soon

@lazy02
Copy link

lazy02 commented Sep 6, 2018 via email

Mark Vulfson and others added 4 commits September 20, 2018 10:21
* Ensure all new methods/classes have XML docs
* Ensure all memebers have access modifiers
Using Costura to merge the needed binaries into the RTF assemblies
such that they don't need to be redistributed without correct nuget usage
@marchello2000
Copy link
Contributor Author

@mjkkirschner : sorry for the delay. I have pushed the feedback changes to this PR. If you want to view just those changes: 07137c0

Aside from unit testing the changes, I believe I addressed all comments. Unit testing is tricky because the runner aspect of the codebase isn't really unittested. I will look into adding a bunch more mocks to add the tests. But that should be a separate PR as a) I am not sure when I'll get to it and b) it's already getting quite huge.

Note that I have removed the .yml file for the appveyor build. But I can work with your and your team to add it such that it's being built from your appveyor account.

Let me know how you want to proceed

@mjkkirschner
Copy link
Member

@QilongTang @smangarole @ZiyunShang is there any problem merging this in now or should we wait until after any cross team handoffs are made - I don't want to distrub the builds if they consume master RTF or something like that?

@mjkkirschner
Copy link
Member

Also note that if this is merged we must take on the work of fixing up the nugets - I don't think it is appropriate to merge these dlls - like prism for too long without at-least including their licenses in this repo.

@mjkkirschner
Copy link
Member

@marchello2000 thanks for the hardwork, I'm planning to get this in soon or some version of it. I'm still a bit confused about the use of frody.costura- can you tell me what assemblies are being merged to the revitTestFramework assemblies and for what purpose?

@marchello2000
Copy link
Contributor Author

@mjkkirschner : apologies for the delay.
The Costura plugin for Fody basically performs ILMerge on the final assembly. This way, for example, Microsft.Practices.Prism.dll doesn't need to go into the Nuget because it's "linked"/"merged" directly into the RevitTestFrameworkGUI.exe. (https://github.com/DynamoDS/RevitTestFramework/pull/87/files#diff-500dbf6051225bb795faa5da2c76346fR19)

I also added a licenses.txt file into the repo & nuget to address licensing concerns. (https://github.com/DynamoDS/RevitTestFramework/pull/87/files#diff-0714f5678ce40fb39fb7f5631869fc7fR1)

@Garrett-R
Copy link

Garrett-R commented Nov 28, 2018

Hey, just curious, think you folks will have any time to continue with this code review?

@ZiyunShang ZiyunShang merged commit 53a4d9e into DynamoDS:Revit2019 Mar 22, 2019
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.

None yet

5 participants