I am trying to automate testing for a program written in Java. The problem I have is that there needs to be a way to add/remove more tests cases without changing the code.
For example, you have two strings and want to check if they are within a list of strings. You pass the the strings over and check. In Java code, I could make an if statement and check if the two strings match some string in a given list. However, if I wanted to add more strings to search for from that list, I would have to go back to the program and add more code.
Probably a bad example, but I hope you get my point. Of course, there can be many more test cases that might be completely different. And if I wanted to give the program to someone else, they might want to add their own as well.
I was thinking to create some kind of template with arguments and method names to call that's outside of the code. Basically a file with rules. The Java code will then interpret what to do with the given rules. I was reading this: https://blog.codecentric.de/en/2016/01/robot-framework-tutorial-2016-keywords/ but wasn't really understanding it.
My goal is to write some generic Java code that can interpret a template file and run the test cases defined in there. Any help would be appreciated, thank you!
Example:
Template file
Details: Checks if String in database
Method: testID
Arguments: Hello
Foobar.java
public class Foobar {
public void testID(String str1)
{
// Expected output will be taken from a database
Assert.assertEquals(str1, expected_output);
}
}
The String str1
can be taken from the template file under Arguments.
The problem with this is that if I now want to test if str1
is a certain length, I would have to go back and add more code. This would be fine if the program was just for me and my team. However, when you give it to another company or person that doesn't know how to code but they want to run their own tests, it won't be that functional. That's why I was hoping, a person not on the team could just add their test case given they follow the format of the template and the Java program will know what to do with it.
I'm sorry I don't know how to explain it that well. Hope it's not confusing.