AlexeyDmitriev / JHelper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Having function instead of class causes tests to be invalid

mehranagh20 opened this issue · comments

I've changed the task, submission and template files so I can have a function instead of class.

It compiles and works but because of global static arrays and variables which are initialized to 0 for the first test but later for other tests they are changed and affected by previous tests result of tests changes.

How can I have a fresh start for each test and avoid having classes?

@AlexeyDmitriev Do you have any solution for this problem? :)

@mehranagh20 Sorry for late answer.

I do not have solution for this except using local variables (and pass them to other functions and/or capture them by lambdas). Note, that static and global variables still will not work even with classes (but you may use fields).
You may find relevant discussion/design consideration in #97

Please let me know if you have other questions/comments on that

@AlexeyDmitriev Thanks for your response.
Do you think is it somehow possible to re-execute the code for each test?