I'm having trouble understanding how assert in java works. I want to make so that if the assert is not true then the test should fail. The following example should returns false but the test does not fail. What I'm I missing?
Example:
package test;
public class tests {
public static void main(String[] args) {
// TODO Auto-generated method stub
tests s = new tests();
s.approve(500);
}
public boolean approve(int age)
{
assert (age < 60) :"Test Failed" ;
if (age > 100)
{
return true;
}
else
{
return false;
}
}
}
-eapassed to the VM? By default assertions are disabled.