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

Group tests by model with the GroupByModel param #83

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ x64/
build/
[Bb]in/
[Oo]bj/
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ A console application which allows running RTF without a user interface. If you'
--dry Conduct a dry run. (OPTIONAL)
-x, --clean Cleanup journal files after test completion. (OPTIONAL)
--continuous Run all selected tests in one Revit session. (OPTIONAL)
--groupByModel Run tests with same model without reopening the model for faster execution, requires --continuous. (OPTIONAL)
--time The time, in milliseconds, after which RTF will close the testing process automatically. (OPTIONAL)
-d, --debug Should RTF attempt to attach to a debugger?. (OPTIONAL)
-h, --help Show this message and exit. (OPTIONAL)
Expand Down
12 changes: 10 additions & 2 deletions src/Applications/RevitTestFrameworkGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
xmlns:applications="clr-namespace:RTF.Applications"
xmlns:runners="clr-namespace:RTF.Framework;assembly=Runner"
xmlns:System="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" MinWidth="400" MinHeight="600" SizeToContent="Height" Width="800" Closing="View_Closing">
mc:Ignorable="d" MinWidth="400" MinHeight="600" Height="800" Width="800" Closing="View_Closing"
d:DataContext="{d:DesignInstance applications:RunnerViewModel}"
Title="RevitTestFrameworkGUI"
>

<Window.Resources>
<applications:AssemblyPathConverter x:Key="AssemblyPathConverter"></applications:AssemblyPathConverter>
Expand Down Expand Up @@ -122,7 +125,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height ="Auto"/>
</Grid.RowDefinitions>

<StackPanel Grid.Row="0">

<Menu>
Expand Down Expand Up @@ -265,6 +268,11 @@
<TextBlock Text="When selected, all tests will be run in the same Revit session."></TextBlock>
</CheckBox.ToolTip>
</CheckBox>
<CheckBox Content="Group by model" IsChecked="{Binding Path=GroupByModel, Mode=TwoWay}" VerticalAlignment="Center" Margin="20,0,0,0">
<CheckBox.ToolTip>
<TextBlock Text="When selected, all tests with the same model will run without reopening the model (requires Continuous)."></TextBlock>
</CheckBox.ToolTip>
</CheckBox>
<TextBlock Text="Sort By:" Margin="20,0,0,0" VerticalAlignment="Center"></TextBlock>
<ComboBox Margin="5,0,0,0"
Width="100"
Expand Down
6 changes: 6 additions & 0 deletions src/Applications/RevitTestFrameworkGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public MainWindow()

Closing += View_Closing;
Loaded += MainWindow_Loaded;

var args = Environment.GetCommandLineArgs();
if (args.Length == 2)
{
vm.TestAssembly = args[1];
}
}

void MainWindow_Loaded(object sender, RoutedEventArgs e)
Expand Down
108 changes: 77 additions & 31 deletions src/Applications/RevitTestFrameworkGUI/RunnerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Threading;
using Autodesk.RevitAddIns;
using Microsoft.Practices.Prism;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Win32.SafeHandles;
using RTF.Applications.Properties;
using RTF.Framework;
using MessageBox = System.Windows.MessageBox;
Expand Down Expand Up @@ -86,6 +86,8 @@ public class RunnerViewModel : NotificationObject
private ObservableCollection<string> recentFiles = new ObservableCollection<string>();
private int selectedProductIndex;

private bool workingDirSetByUser = false;
private bool resultsFileSetByUser = false;
#endregion

#region public properties
Expand All @@ -96,8 +98,8 @@ public object SelectedItem
set
{
selectedItem = value;
RaisePropertyChanged("SelectedItem");
RaisePropertyChanged("RunText");
RaisePropertyChanged();
RaisePropertyChanged(nameof(RunText));
RunCommand.RaiseCanExecuteChanged();
}
}
Expand Down Expand Up @@ -138,7 +140,7 @@ public string RunText
}
set
{
RaisePropertyChanged("RunText");
RaisePropertyChanged();
}
}

Expand All @@ -156,7 +158,7 @@ public bool IsRunning
lock (isRunningLock)
{
isRunning = value;
RaisePropertyChanged("IsRunning");
RaisePropertyChanged();
}
}
}
Expand All @@ -180,8 +182,8 @@ public ObservableCollection<string> RecentFiles
set
{
recentFiles = value;
RaisePropertyChanged("RecentFiles");
RaisePropertyChanged("HasRecentFiles");
RaisePropertyChanged();
RaisePropertyChanged(nameof(HasRecentFiles));
}
}

Expand All @@ -206,7 +208,7 @@ public bool IsDebug
set
{
runner.IsDebug = value;
RaisePropertyChanged("IsDebug");
RaisePropertyChanged();
}
}

Expand All @@ -216,7 +218,7 @@ public bool Concat
set
{
runner.Concat = value;
RaisePropertyChanged("Concat");
RaisePropertyChanged();
}
}

Expand All @@ -226,7 +228,7 @@ public int Timeout
set
{
runner.Timeout = value;
RaisePropertyChanged("Timeout");
RaisePropertyChanged();
}
}

Expand All @@ -237,8 +239,8 @@ public string WorkingDirectory
{
runner.WorkingDirectory = value;
runner.InitializeTests();
RaisePropertyChanged("WorkingDirectory");
RaisePropertyChanged("Assemblies");
RaisePropertyChanged();
RaisePropertyChanged(nameof(Assemblies));
}
}

Expand All @@ -248,7 +250,20 @@ public bool Continuous
set
{
runner.Continuous = value;
RaisePropertyChanged("Continuous");
RaisePropertyChanged();
}
}

public bool GroupByModel
{
get { return runner.GroupByModel; }
set
{
if (runner.GroupByModel != value)
{
runner.GroupByModel = value;
RaisePropertyChanged();
}
}
}

Expand All @@ -259,8 +274,8 @@ public GroupingType GroupingType
{
runner.GroupingType = value;
runner.InitializeTests();
RaisePropertyChanged("GroupingType");
RaisePropertyChanged("Assemblies");
RaisePropertyChanged();
RaisePropertyChanged(nameof(Assemblies));
}
}

Expand All @@ -271,8 +286,21 @@ public string TestAssembly
{
runner.TestAssembly = value;
runner.InitializeTests();
RaisePropertyChanged("TestAssembly");
RaisePropertyChanged("Assemblies");
RaisePropertyChanged();
RaisePropertyChanged(nameof(Assemblies));

RaisePropertyChanged(nameof(SelectedProductIndex));

// Infer working directory from assembly, if the user hasn't set it yet
if (!workingDirSetByUser)
{
SetWorkingDirectory(runner.TestAssembly);
}

if (!resultsFileSetByUser)
{
SetResultsPath(Path.Combine(WorkingDirectory, "results.xml"));
}
}
}

Expand All @@ -282,7 +310,7 @@ public string Results
set
{
runner.Results = value;
RaisePropertyChanged("Results");
RaisePropertyChanged();
}
}

Expand All @@ -302,7 +330,7 @@ public string AdditionalResolutionDirectoriesText
{
runner.AdditionalResolutionDirectories.Add(split);
}
RaisePropertyChanged("AdditionalResolutionDirectoriesText");
RaisePropertyChanged();
}
}
#endregion
Expand Down Expand Up @@ -333,6 +361,10 @@ internal RunnerViewModel(IContext context)
InitializeRunner();

InitializeCommands();

// Make some convenient defaults
Continuous = true;
GroupByModel = true;
}

private void InitializeRunner()
Expand Down Expand Up @@ -448,7 +480,7 @@ private void runner_TestComplete(IEnumerable<ITestData> data, string resultsPath
context.BeginInvoke(() => Runner.GetTestResultStatus(data, resultsPath));
}

void Products_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
void Products_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
// When the products collection is changed, we want to set
// the selected product index to the first in the list
Expand All @@ -461,12 +493,12 @@ void Products_CollectionChanged(object sender, System.Collections.Specialized.No
// SelectedProductIndex = -1;
//}

RaisePropertyChanged("Products");
RaisePropertyChanged(nameof(Products));
}

void Assemblies_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
RaisePropertyChanged("Assemblies");
RaisePropertyChanged(nameof(Assemblies));
}

#endregion
Expand Down Expand Up @@ -540,6 +572,7 @@ private void SetWorkingDirectory(string path)
if (dirs.ShowDialog() == DialogResult.OK)
{
WorkingDirectory = dirs.SelectedPath;
workingDirSetByUser = true;
}
}
else
Expand Down Expand Up @@ -572,27 +605,31 @@ private void SetResultsPath(string path)
{
var files = new SaveFileDialog()
{
InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Filter = "xml files (*.xml) | *.xml",
RestoreDirectory = true,
DefaultExt = ".xml"
};

if (Directory.Exists(Path.GetDirectoryName(TestAssembly)))
{
files.InitialDirectory = TestAssembly;
}
else
{
files.InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}

var filesResult = files.ShowDialog();

if (filesResult != null && filesResult == true)
{
Results = files.FileName;
resultsFileSetByUser = true;
RunCommand.RaiseCanExecuteChanged();
}
}
else
{
if (!File.Exists(path))
{
return;
}

var fi = new FileInfo(path);
if (fi.Extension != ".xml")
{
Expand All @@ -614,7 +651,6 @@ private void SetAssemblyPath(string path)
{
var files = new OpenFileDialog
{
InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Filter = "assembly files (*.dll)|*.dll| executable files (*.exe)|*.exe",
RestoreDirectory = true,
DefaultExt = ".dll"
Expand Down Expand Up @@ -655,7 +691,7 @@ private void Cancel()

private void Update()
{
RaisePropertyChanged("SelectedTestSummary");
RaisePropertyChanged(nameof(SelectedTestSummary));
}

private bool CanUpdate()
Expand Down Expand Up @@ -783,7 +819,7 @@ private void OpenFile(object parameter)
InitializeEventHandlers();

RaisePropertyChanged("");
RaisePropertyChanged("SelectedProductIndex");
RaisePropertyChanged(nameof(SelectedProductIndex));

SaveRecentFile(fileName);
}
Expand All @@ -808,5 +844,15 @@ private bool CanCleanup()
}

#endregion

/// <summary>
/// Helper method to allow simple RaisePropertyChanged() calls without
/// providing property name, since the Prism's NotificationObject
/// doesn't provide the CallerMemeberName attribute
/// </summary>
protected override void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
base.RaisePropertyChanged(propertyName);
}
}
}
2 changes: 1 addition & 1 deletion src/Framework/RevitTestFramework/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public DefaultAssemblyResolver(string revitDirectory, List<string> additionalDir

public virtual Assembly Resolve(object sender, ResolveEventArgs args)
{
Console.WriteLine("Attempting to resolve referenced assembliy: {0}", args.Name);
Console.WriteLine("Attempting to resolve referenced assembly: {0}", args.Name);

var dir = Path.GetDirectoryName(args.RequestingAssembly.Location);
var testFile = Path.Combine(dir, new AssemblyName(args.Name).Name + ".dll");
Expand Down
Loading