-
Notifications
You must be signed in to change notification settings - Fork 201
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
Adding VCL GUI Logger #147
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
bd16106
Merge remote-tracking branch 'refs/remotes/VSoftTechnologies/master'
rmcginty dd8cc55
Merge remote-tracking branch 'refs/remotes/origin/master' into VSoftT…
rmcginty 0077c5c
Adding VCL GUI Logger support
rmcginty ee274ce
Removing deleted DUnitX.Loggers.GUI references
rmcginty 5938c69
Removing commented lines and updating if/else convention
rmcginty cc61bc8
Changing Filters to TStrings, added message when test result couldn't…
rmcginty 430da56
Attempt at isolating changes to Assert, updated test name in assert t…
rmcginty 2a09b05
Forcing sort of test tree
rmcginty ad2ed0a
Updating DUnitX.Examples.General to give a better example of using Ig…
rmcginty f0bcdd8
Adding GUID support to Assert, updating Assert tests, adding tests fo…
rmcginty fc19687
Adding Warnings for no assertions (similar to TestInsight), bug fixes
rmcginty 73a3cc5
Adding IgnoreCaseDefault property to Assert class
rmcginty 2e23289
Fixing issue with GUI not showing tests in fixtures that also had chi…
rmcginty 04b01f0
Fixed issue that made TestCase attribute with RepeatTest result in Fu…
rmcginty 6d8a679
Changing Writeln to Logging to make compatible with non-console runners
rmcginty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{***************************************************************************} | ||
{ } | ||
{ DUnitX } | ||
{ } | ||
{ Copyright (C) 2016 Vincent Parrett } | ||
{ } | ||
{ vincent@finalbuilder.com } | ||
{ http://www.finalbuilder.com } | ||
{ } | ||
{ } | ||
{***************************************************************************} | ||
{ } | ||
{ Licensed under the Apache License, Version 2.0 (the "License"); } | ||
{ you may not use this file except in compliance with the License. } | ||
{ You may obtain a copy of the License at } | ||
{ } | ||
{ http://www.apache.org/licenses/LICENSE-2.0 } | ||
{ } | ||
{ Unless required by applicable law or agreed to in writing, software } | ||
{ distributed under the License is distributed on an "AS IS" BASIS, } | ||
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } | ||
{ See the License for the specific language governing permissions and } | ||
{ limitations under the License. } | ||
{ } | ||
{***************************************************************************} | ||
|
||
unit DUnitX.Assert.Ex; | ||
|
||
// This unit should contain DUnitX specific Assert commands and mechanisms | ||
// in order to keep DUnitX.Assert framework neutral and usable in other | ||
// test frameworks such as DUnit. | ||
|
||
interface | ||
|
||
{$I DUnitX.inc} | ||
|
||
uses | ||
DUnitX.Assert, | ||
DUnitX.ComparableFormat; | ||
|
||
type | ||
Assert = class(DUnitX.Assert.Assert) | ||
private | ||
class procedure FailStrCompare(const expected, actual: string; const compformat: TDUnitXComparableFormatClass = nil; const message : string = ''; const errorAddrs : pointer = nil); | ||
public | ||
class procedure AreEqual(const expected, actual : string; const compformat: TDUnitXComparableFormatClass; const ignoreCase : boolean; const message : string = ''); overload; | ||
class procedure AreEqual(const expected, actual : string; const compformat: TDUnitXComparableFormatClass; const message : string = ''); overload; | ||
|
||
//Reintroduced from Assert to throw ETestFailureStrCompare | ||
class procedure AreEqual(const expected : string; const actual : string; const ignoreCase : boolean; const message : string = ''); reintroduce; overload; | ||
//Reintroduced from Assert to throw ETestFailureStrCompare | ||
class procedure AreEqual(const expected : string; const actual : string; const message : string = ''); reintroduce; overload; | ||
end; | ||
|
||
implementation | ||
|
||
uses | ||
{$IFDEF USE_NS} | ||
System.SysUtils, | ||
{$ELSE} | ||
SysUtils, | ||
{$ENDIF} | ||
DUnitX.ResStrs, | ||
DUnitX.Exceptions; | ||
|
||
class procedure Assert.AreEqual(const expected, actual: string; const compformat: TDUnitXComparableFormatClass; const ignoreCase: boolean; const message: string); | ||
begin | ||
DoAssert; | ||
if ignoreCase then | ||
begin | ||
if not SameText(expected,actual) then | ||
FailStrCompare(expected, actual, compformat, message, ReturnAddress); | ||
end | ||
else if not SameStr(expected,actual) then | ||
FailStrCompare(expected, actual, compformat, message, ReturnAddress); | ||
end; | ||
|
||
class procedure Assert.AreEqual(const expected, actual: string; const compformat: TDUnitXComparableFormatClass; const message: string); | ||
begin | ||
AreEqual(expected, actual, compformat, IgnoreCaseDefault, message); | ||
end; | ||
|
||
class procedure Assert.AreEqual(const expected, actual : string; const ignoreCase : boolean; const message: string); | ||
begin | ||
AreEqual(expected, actual, nil, ignoreCase, message); | ||
end; | ||
|
||
class procedure Assert.AreEqual(const expected : string; const actual : string; const message : string); | ||
begin | ||
Assert.AreEqual(expected, actual, IgnoreCaseDefault, message); | ||
end; | ||
|
||
class procedure Assert.FailStrCompare(const expected, actual: string; const compformat : TDUnitXComparableFormatClass; const message: string; const errorAddrs: pointer); | ||
begin | ||
//If we have been given a return then use it. (makes the exception appear on level above in the stack) | ||
if errorAddrs <> nil then | ||
raise ETestFailureStrCompare.Create(expected, actual, message, compformat) at errorAddrs | ||
else | ||
//Otherwise use the return address we can currently get to for where to raise the exception | ||
raise ETestFailureStrCompare.Create(expected, actual, message, compformat) at ReturnAddress; | ||
end; | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{***************************************************************************} | ||
{ } | ||
{ DUnitX } | ||
{ } | ||
{ Copyright (C) 2016 Vincent Parrett } | ||
{ } | ||
{ vincent@finalbuilder.com } | ||
{ http://www.finalbuilder.com } | ||
{ } | ||
{ } | ||
{***************************************************************************} | ||
{ } | ||
{ Licensed under the Apache License, Version 2.0 (the "License"); } | ||
{ you may not use this file except in compliance with the License. } | ||
{ You may obtain a copy of the License at } | ||
{ } | ||
{ http://www.apache.org/licenses/LICENSE-2.0 } | ||
{ } | ||
{ Unless required by applicable law or agreed to in writing, software } | ||
{ distributed under the License is distributed on an "AS IS" BASIS, } | ||
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } | ||
{ See the License for the specific language governing permissions and } | ||
{ limitations under the License. } | ||
{ } | ||
{***************************************************************************} | ||
|
||
unit DUnitX.ComparableFormat.Csv; | ||
|
||
interface | ||
|
||
{$I DUnitX.inc} | ||
|
||
uses | ||
DUnitX.ComparableFormat; | ||
|
||
type | ||
TDUnitXComparableFormatCsv = class abstract(TDUnitXComparableFormat); | ||
|
||
implementation | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{***************************************************************************} | ||
{ } | ||
{ DUnitX } | ||
{ } | ||
{ Copyright (C) 2016 Vincent Parrett } | ||
{ } | ||
{ vincent@finalbuilder.com } | ||
{ http://www.finalbuilder.com } | ||
{ } | ||
{ } | ||
{***************************************************************************} | ||
{ } | ||
{ Licensed under the Apache License, Version 2.0 (the "License"); } | ||
{ you may not use this file except in compliance with the License. } | ||
{ You may obtain a copy of the License at } | ||
{ } | ||
{ http://www.apache.org/licenses/LICENSE-2.0 } | ||
{ } | ||
{ Unless required by applicable law or agreed to in writing, software } | ||
{ distributed under the License is distributed on an "AS IS" BASIS, } | ||
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } | ||
{ See the License for the specific language governing permissions and } | ||
{ limitations under the License. } | ||
{ } | ||
{***************************************************************************} | ||
|
||
unit DUnitX.ComparableFormat.Xml; | ||
|
||
interface | ||
|
||
{$I DUnitX.inc} | ||
|
||
uses | ||
DUnitX.ComparableFormat; | ||
|
||
type | ||
TDUnitXComparableFormatXml = class abstract(TDUnitXComparableFormat); | ||
|
||
implementation | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{***************************************************************************} | ||
{ } | ||
{ DUnitX } | ||
{ } | ||
{ Copyright (C) 2016 Vincent Parrett } | ||
{ } | ||
{ vincent@finalbuilder.com } | ||
{ http://www.finalbuilder.com } | ||
{ } | ||
{ } | ||
{***************************************************************************} | ||
{ } | ||
{ Licensed under the Apache License, Version 2.0 (the "License"); } | ||
{ you may not use this file except in compliance with the License. } | ||
{ You may obtain a copy of the License at } | ||
{ } | ||
{ http://www.apache.org/licenses/LICENSE-2.0 } | ||
{ } | ||
{ Unless required by applicable law or agreed to in writing, software } | ||
{ distributed under the License is distributed on an "AS IS" BASIS, } | ||
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } | ||
{ See the License for the specific language governing permissions and } | ||
{ limitations under the License. } | ||
{ } | ||
{***************************************************************************} | ||
|
||
unit DUnitX.ComparableFormat; | ||
|
||
interface | ||
|
||
{$I DUnitX.inc} | ||
|
||
type | ||
TDUnitXComparableFormat = class abstract(TObject); | ||
TDUnitXComparableFormatClass = class of TDUnitXComparableFormat; | ||
|
||
implementation | ||
|
||
end. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh - did you understand what these fields were for? This was to not couple the assert class with the framework (yes, I could use this in a DUnit project!) but now you went back how it was before by hardcoding the exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that is why this was done. There weren't any comments explaining that, so I thought it was just something left over from the past, or a way around a circular reference. I had to eliminate the "generic" exception because I couldn't get away with just message - I needed to add custom data to the exception. I could revert the changes and make some new exception classes, but dumb down to the lowest common denominator if any class var is nil (for instance, if fTestFailureStrCompare = nil, raise fTestFailure) and I think that would satisfy the requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you might want to add your new feature either as helper for the Assert class or via Event that can produce the proper exception. In any case try to keep Assert as simple as possible without cluttering it with special framework related cases (personally I see the diffing logic as special case).
I for example also had the problem of comparing long strings (xml) via unit test and the DUnit error message was not very helpful telling me that differs from so I implemented my own CheckEqualsString method that only shows a snippet where the strings differ and the position where that is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Assert is going to need to stay framework-agnostic, then yes my changes will have to be done differently. I can't really go the helper route because you can only have one helper per class and the helper would also have to be included in the project or a uses clause (could confuse people), and that would limit anyone else from adding a helper later. One of my goals was to integrate this directly in Assert. While you consider the diffing logic a special case, it is not only for diffing, that is just how the GUI logger uses it. It could be used by automated systems to save the data out and add as artifacts in the CI so people could review the output in a more digestible format. The problem is the data that you are asserting is locked in a string error message which makes it hard to act on if desired.
While I knew Assert was supposed to remain as self-contained as possible (which it still is), I did not know it was supposed to remain framework independent (which it now is not because of the exceptions). I will see about getting the latter back - I am not exactly sure the best way to do that but will explore some options.