Get the list of variables needed by testcase

I’m currently working on a kind of old project many people have worked on. We realized that some people just copied and pasted other test case variables and added extra variables that the test cases were not using. We want to clean the variables, is there any way to get the variables needed by the test cases?

The goal is to get the list of variables needed by the test case and then compare it with the declared ones so we can do some variable cleaning. There are several test cases and it will take us a lot of time to check one by one.

Hi Wilson,

So many possibilities and so many potential pitfalls.

  • An easy one, but this will depend on your editor, some editors will show you how many times a value is found in the current file, e.g. my editor does this:

    so you could simply open the file double click the declared variable and do a find all, if you get a count of 1 it’s possibly safe to remove
  • If you have many test cases but the declared variables are all the same, you could use something like grep to return only the lines that have that variable for each robot file, again if it’s only the deceleration line it’s possibly safe to remove

Now a potential pitfall to think about:

  • do these test cases import common resource files with keywords in them?

    • do the keywords in those resource files expect these declared variables?
    • how about the resource files that are imported buy the resource file?
  • Hopefully these test cases are checked into some sort of version control and you can make a branch for these changes? I’m guessing you wouldn’t want a release to fail from your cleanup.

I know this is kind of generic, but hopefully it’ll help,