Skip to content

Commit 75f3271

Browse files
committed
Issue #5564: do not exit the sub 'catch' with next
also add an assertion that checks whether an expected excption was actually thrown
1 parent 344efb9 commit 75f3271

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,23 @@ for my $Test (@Tests) {
207207

208208
# implicitly call Kernel::System::Web::Request->new();
209209
my %ObjectData;
210+
my $HasThrown;
210211
try {
211212
%ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );
212213
}
213214
catch {
214-
215-
if( !$Test->{Throws} ) {
215+
$HasThrown = 1;
216216

217-
ok(0,"$Test->{Name} - not expected to throw");
217+
if ( $Test->{Throws} ) {
218+
pass("$Test->{Name} should throw");
219+
}
220+
else {
221+
fail("$Test->{Name} should not throw");
218222
}
219-
next TEST;
220223
};
221224

225+
next TEST if $HasThrown;
226+
222227
if ( !$Test->{Success} ) {
223228
is(
224229
\%ObjectData,

scripts/test/DynamicField/ObjectType/Ticket/ObjectDataGet.t

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,23 @@ for my $Test (@Tests) {
163163

164164
# implicitly call Kernel::System::Web::Request->new();
165165
my %ObjectData;
166+
my $HasThrown;
166167
try {
167168
%ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );
168169
}
169170
catch {
170-
171-
if( !$Test->{Throws} ) {
172-
173-
ok( 0, "$Test->{Name} should not throw");
171+
$HasThrown = 1;
172+
173+
if ( $Test->{Throws} ) {
174+
pass("$Test->{Name} should throw");
175+
}
176+
else {
177+
fail("$Test->{Name} should not throw");
174178
}
175-
next TEST;
176179
};
177180

181+
next TEST if $HasThrown;
182+
178183
if ( !$Test->{Success} ) {
179184
is(
180185
\%ObjectData,

0 commit comments

Comments
 (0)