Skip to content

Commit

Permalink
Improve tests for DynamicClass checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MaisiKoleni committed May 4, 2021
1 parent 64530fc commit 71a83a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/test/java/de/tum/in/test/api/DynamicsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void test_class_searchNonPrivateFields() {
@TestTest
void test_class_searchPublicOrProtectedMethods() {
tests.assertThatEvents().haveExactly(1, testFailedWith(class_searchPublicOrProtectedMethods,
AssertionFailedError.class, "Methode throwException() ist public, sollte sie aber nicht"));
AssertionFailedError.class, "Methode doSomething(java.lang.String) ist public, sollte sie aber nicht"));
}

@TestTest
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/de/tum/in/testuser/DynamicsUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,29 @@ void class_notFound() {

@Test
void class_searchNonFinalFields() {
int checked = DynamicClass.toDynamic(DynamicsUser.class).checkForNonFinalFields();
assertThat(checked).isEqualTo(12);

SomeClass.checkForNonFinalFields();
}

@Test
void class_searchNonPrivateFields() {
int checked = DynamicClass.toDynamic(DynamicsUser.class).checkForNonPrivateFields();
assertThat(checked).isEqualTo(12);

SomeClass.checkForNonPrivateFields();
}

@Test
void class_searchPublicOrProtectedMethods() {
SomeClass.checkForPublicOrProtectedMethods();
int checked = DynamicClass.toDynamic(SUBJECT_PACKAGE + ".SomeAbstractClass").checkForPublicOrProtectedMethods();
assertThat(checked).isOne();

SomeClass.checkForPublicOrProtectedMethods(SomeClass_getSomeAttribute, SomeClass_doSomethingElse,
SomeClass_throwException, SomeClass.method(Integer.class, "getAnotherAttribute"),
SomeClass.method(void.class, "setSomeAttribute", String.class),
SomeClass.method(Class.class, "initializeFailingClass"));
}

@Test
Expand Down

0 comments on commit 71a83a6

Please sign in to comment.