Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-7262

YamlExtensionTestCase should not be asserting on complete error traces and use message IDs instead

XMLWordPrintable

      YamlExtensionTestCase is asserting test cases by inspecting concrete log traces, for example:

      @Test
          public void testUndefineNonExistentAttributeYamlOperations() {
              ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
              try {
                  container.startYamlExtension(new PrintStream(byteArrayOutputStream), new Path[]{testUndefineNonExistentAttributeYamlOperations});
                  Assert.fail("Server must not start with non-existent attribute.");
              } catch (RuntimeException ex) {
                  Assert.assertFalse("Server must not start with non-existent attribute.", container.isStarted());
                  String expectedConsoleOutput = "ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation (\"undefine-attribute\") failed - address: ([\n"
                          + "    (\"socket-binding-group\" => \"standard-sockets\"),\n"
                          + "    (\"socket-binding\" => \"txn-status-manager\")\n"
                          + "]) - failure description: \"WFLYCTL0201: Unknown attribute 'asfds'\"";
                  assertThat("Server log must contain ERROR with information which attribute is wrong.", byteArrayOutputStream.toString(), CoreMatchers.containsString(expectedConsoleOutput));
              }
          }
      

      This makes the code harder to maintain. Instead, it should use the message ID and maybe other specific patterns using a regular expression, but we should avoid checking exact error traces.

              yborgess1@redhat.com Yeray Borges Santana
              yborgess1@redhat.com Yeray Borges Santana
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: