Home How to test OS-specific method with JUnit?
Reply: 0

How to test OS-specific method with JUnit?

user506 Published in July 20, 2018, 2:35 pm

I would like to test the following method with JUnit:

private static boolean systemIsWindows() {
    String os = System.getProperty("os.name").toLowerCase();
    return os.startsWith("win");

Frankly, the only thing I've come up with is to basically copy to same logic to the test. This would, of course, protect against the method being inadvertently broken, but sounds somehow counter-intuitive.

What would be a better way to test this method?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.326448 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO