Loading ...
Sorry, an error occurred while loading the content.

Signalling unsupported tests?

Expand Messages
  • org.junit@io7m.com
    Hello. I have a set of test cases that cannot be executed on certain systems (they involve OpenGL, and some features of OpenGL are optional and cannot be
    Message 1 of 4 , Dec 3, 2012
    • 0 Attachment
      Hello.

      I have a set of test cases that cannot be executed on certain systems
      (they involve OpenGL, and some features of OpenGL are optional and
      cannot be determined to be supported until runtime).

      Is there some way I can have a test signal that it is not supported and
      should therefore silently pass?

      I can obviously write "if (isSupported()) { ..." at the start of every
      test, but this involves quite a lot of manual labour (and also requires me
      to manually throw exceptions in the case of tests that expect exceptions to
      be thrown).
    • David Saff
      You can write assumeTrue(someCondition()) at the beginning of any test, and the test will be skipped if someCondition() returns false. You can also put it in
      Message 2 of 4 , Dec 3, 2012
      • 0 Attachment
        You can write assumeTrue(someCondition()) at the beginning of any test, and
        the test will be skipped if someCondition() returns false. You can also
        put it in a @BeforeClass method in order to skip an entire class if
        someCondition() fails.

        David


        On Mon, Dec 3, 2012 at 11:25 AM, <org.junit@...> wrote:

        > **
        >
        >
        > Hello.
        >
        > I have a set of test cases that cannot be executed on certain systems
        > (they involve OpenGL, and some features of OpenGL are optional and
        > cannot be determined to be supported until runtime).
        >
        > Is there some way I can have a test signal that it is not supported and
        > should therefore silently pass?
        >
        > I can obviously write "if (isSupported()) { ..." at the start of every
        > test, but this involves quite a lot of manual labour (and also requires me
        > to manually throw exceptions in the case of tests that expect exceptions to
        > be thrown).
        >
        >


        [Non-text portions of this message have been removed]
      • org.junit@io7m.com
        On Mon, 3 Dec 2012 13:24:05 -0500 ... Ah, thanks. Sounds ideal.
        Message 3 of 4 , Dec 3, 2012
        • 0 Attachment
          On Mon, 3 Dec 2012 13:24:05 -0500
          David Saff <saff@...> wrote:

          > You can write assumeTrue(someCondition()) at the beginning of any test, and
          > the test will be skipped if someCondition() returns false. You can also
          > put it in a @BeforeClass method in order to skip an entire class if
          > someCondition() fails.
          >
          > David

          Ah, thanks. Sounds ideal.
        • Jens Schauder
          Since it sounds you have lots of tests with the same or similar condition, you might consider putting it into a Rule [Non-text portions of this message have
          Message 4 of 4 , Dec 4, 2012
          • 0 Attachment
            Since it sounds you have lots of tests with the same or similar condition,
            you might consider putting it into a Rule


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.