Skip to content

Commit eed09a8

Browse files
committed
fix exception conversion
1 parent 1f96297 commit eed09a8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

scripts/testng-junit/src/testng2junit5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ def migrate_exceptions(content):
309309
method_signature += line
310310

311311
if '{' in line:
312+
leading_space_count = len(line) - len(line.lstrip())
312313
# parse out method lines
313314
line = next(content_iter)
314-
while not line.startswith(' }'):
315-
# 4 spaces.
315+
while not line.startswith(' ' * leading_space_count + '}'):
316316
method_body.append(' '+line)
317317
line = next(content_iter)
318318

scripts/testng-junit/src/tests/test_migrate_exception.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
new RateTierImpl(-1, -5.0, 0.0, 1.0);
5151
}
5252
53+
@Test(expectedExceptions = IllegalArgumentException.class)
54+
void testDuplicateSignalNameThrowsException() {
55+
final Config config = createConfig(120,
56+
List.of(Pair.of("test", 1), Pair.of("test", 1)));
57+
}
5358
"""
5459

5560
expected = """
@@ -129,6 +134,17 @@
129134
}
130135
);
131136
}
137+
138+
@Test
139+
void testDuplicateSignalNameThrowsException() {
140+
assertThrows(
141+
IllegalArgumentException.class,
142+
() -> {
143+
final Config config = createConfig(120,
144+
List.of(Pair.of("test", 1), Pair.of("test", 1)));
145+
}
146+
);
147+
}
132148
"""
133149

134150

0 commit comments

Comments
 (0)