MarkRoddy
16 years agoVisitor
BrightScript Testing
I'm finding the write code, push to my roku box, go through each feature and see if it works incredibly frustrating. To the point that I'm thinking about how I could create a unit testing harness so I can automate this process.
I am currently trying to parse a .pls file which has a simple syntax. Being a spoiled python programmer, I'm used to being able to "import configparser" but right now I have to roll my own. I doing so I need to write a lot of supporting routines in order to deal with parsing strings, all of which have well defined behavior which would be easy to write unit tests for, but I am currently stuck deploying and running to find each little error. A testing harness would be extremely useful in this scenario, but before I can write one there are some things I need to figure out first.
* Trapping Errors
If I'm going to report errors I need some capacity to trap them to prevent a harness from stopping execution. What is the equivalent to a try/except block in BrightScript? I've been through the docs and have not found anything that states such functionality explicitly. The closest I seemed to find is the documentation on the Run() function references running a test script as an example, but doesn't go into how one would perform testing oneself. The docs on the Eval() function seem like they might point to a path I could take, but it would probably be difficult without the next item.
* Reflection
In order gather a set of tests to be run there would need to be some capacity to inspect, ideally in a way similar to existing XUnit frameworks. Of course I could manually build up a set of tests into say an array using function references, but this is less ideal as it is time consuming and error prone do to leaving tests out that should be run.
Any advice on these issues or ideas would be greatly appreciated.
I am currently trying to parse a .pls file which has a simple syntax. Being a spoiled python programmer, I'm used to being able to "import configparser" but right now I have to roll my own. I doing so I need to write a lot of supporting routines in order to deal with parsing strings, all of which have well defined behavior which would be easy to write unit tests for, but I am currently stuck deploying and running to find each little error. A testing harness would be extremely useful in this scenario, but before I can write one there are some things I need to figure out first.
* Trapping Errors
If I'm going to report errors I need some capacity to trap them to prevent a harness from stopping execution. What is the equivalent to a try/except block in BrightScript? I've been through the docs and have not found anything that states such functionality explicitly. The closest I seemed to find is the documentation on the Run() function references running a test script as an example, but doesn't go into how one would perform testing oneself. The docs on the Eval() function seem like they might point to a path I could take, but it would probably be difficult without the next item.
* Reflection
In order gather a set of tests to be run there would need to be some capacity to inspect, ideally in a way similar to existing XUnit frameworks. Of course I could manually build up a set of tests into say an array using function references, but this is less ideal as it is time consuming and error prone do to leaving tests out that should be run.
Any advice on these issues or ideas would be greatly appreciated.