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

How to test OS-specific method with JUnit?

user3881 Published in September 19, 2018, 9:23 am

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?

share|improve this question

1 Answer 1

active oldest votes
up vote 4 down vote accepted
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO