How can you use assertTrue and assertFalse in if statements? Just throwing in if statement in front does not work, gives me a syntax error, but it was worth a shot. I tried to make it a string and check value with value.equals() but assert gives an error saying you cannot convert to a string.
public class JNAWinRegTest extends TestCase {
public static void main(String[] args) {
try { assertEquals("Windows 7 Professional", Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductName"));
if(True) ){
System.out.println("True");
}else{
if(False) ){
System.out.println("False");
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
You just call
assertEquals(expected, actual)– ifexpected.equals(actual), the test continues to the next line (and pass when it reaches the last line), if the condition is false, the test fails.No need for additional if / else.