Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing methods that contain timers #79

Open
dacaraway opened this issue Nov 1, 2013 · 4 comments
Open

Testing methods that contain timers #79

dacaraway opened this issue Nov 1, 2013 · 4 comments

Comments

@dacaraway
Copy link

Im experiencing a problem when testing a method that employs a timer task. WHen I run the test it gets into the method but it wont execute the action that is called when the timer expires. How do we get around this?

@EliteSoba
Copy link

You could always just set the timer to 0.

@004forever
Copy link

Does your timer just call a specific function. I just had my test call that function directly

@dacaraway
Copy link
Author

The problem with setting the timer to 0 is that it is in a real agent so it would screw up the actual running of it. My timer sends a message that uses a parameter that is passed into the function so I guess I can just create a function for it to call to send the message. I just thought there might be a special way to get around it with testing.

@EliteSoba
Copy link

Well there are a few ways to do this.
One way is to set a timer in your test that waits for the same amount of time. This is really slow and I don't really suggest it unless you insist on keeping your agents pure.
Another way is the way I previously suggested, setting the timer to 0. As long as you remember to change the timer back when you're actually running the program, you shouldn't run into too many issues.
A third way is simply a better implementation of the second way. You could just use a debug variable that gets set in the constructor. When this debug variable is false, the timers run normally, but when it's set to true, the timers are set to 0.

There are probably a few other ways, likely a few better ways, but what I've suggested will probably be good enough for our purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants