Closed lekoook closed 5 years ago
I assume you are using the Desktop API? Not sure what travis returns for isDesktopSupported​()
Maybe you can check if its false on travis then return AssertionError which you catch in the relevant tests.
Or you can skip the test if its running on travis using something like the following?
@Test
@DisabledIfEnvironmentVariable(named = "TRAVIS", matches = "true")
void skipTestOnTravis() {
// ...
}
Alternatively if isDesktopSupported​()
indeed returns false on TravisCI and you throw an AssertionError, you can catch it using ExpectedException
or assertThrows
@Test
@EnabledIfEnvironmentVariable(named = "TRAVIS", matches = "true")
void catchAssertionOnTravis() {
// ...
}
//Not on travis
@Test
@DisabledIfEnvironmentVariable(named = "TRAVIS", matches = "true")
void testRunsOnYourComputer() {
// ...
}
@QzSG Yup, after fiddling with some changes your suggestions did the trick. In case any wandering souls pass by here, the @Test
annotation to be used in conjunction with @DisabledIfEnvinronmentVariable
has to be from the package org.junit.jupiter.api.Test
instead of the org.junit.Test
AB4 came with. Else, the conditional annotation wouldn't work.
Nonetheless, thanks for your suggestions @QzSG , it pointed me in the right direction.
Good day friends.
Long story short, I have a method that open's the user's system default application for emails when executed. The test code works fine locally (external application opens correctly and all) but on Travis, it doesn't work since Travis does not allow external applications to be opened.
Does anyone else faced similar problem and wouldn't mind sharing your workarounds?