Skip to content

Commit

Permalink
fix exception conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ztai-add committed Sep 1, 2024
1 parent 1f96297 commit eed09a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/testng-junit/src/testng2junit5.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ def migrate_exceptions(content):
method_signature += line

if '{' in line:
leading_space_count = len(line) - len(line.lstrip())
# parse out method lines
line = next(content_iter)
while not line.startswith(' }'):
# 4 spaces.
while not line.startswith(' ' * leading_space_count + '}'):
method_body.append(' '+line)
line = next(content_iter)

Expand Down
16 changes: 16 additions & 0 deletions scripts/testng-junit/src/tests/test_migrate_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
new RateTierImpl(-1, -5.0, 0.0, 1.0);
}
@Test(expectedExceptions = IllegalArgumentException.class)
void testDuplicateSignalNameThrowsException() {
final Config config = createConfig(120,
List.of(Pair.of("test", 1), Pair.of("test", 1)));
}
"""

expected = """
Expand Down Expand Up @@ -129,6 +134,17 @@
}
);
}
@Test
void testDuplicateSignalNameThrowsException() {
assertThrows(
IllegalArgumentException.class,
() -> {
final Config config = createConfig(120,
List.of(Pair.of("test", 1), Pair.of("test", 1)));
}
);
}
"""


Expand Down

0 comments on commit eed09a8

Please sign in to comment.