Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Newbie question : how to test random functionnalities...
In order to try "test-driven programming", I wanted to implement some
statistical functions. Normal law, Binomial law...
First of all, I should write tests for this function and then... How can I
test functions which are aimed to send random results ? May I send to test
functions "pseudo-random" numbers and see if the result is conform to what I
expected ?

Thks for your answers and happy new year,

Emmanuel C.
France (thousands of 'scuse for my frenglish).



Report this thread to moderator Post Follow-up to this message
Old Post
Emmanuel Champommier
01-02-05 08:56 PM


Re: Newbie question : how to test random functionnalities...
Emmanuel,

> Emmanuel C.
> France (thousands of 'scuse for my frenglish).

Try asking the same question on the French XP mailing list as well:
http://fr.groups.yahoo.com/group/xp-france/

Laurent

Report this thread to moderator Post Follow-up to this message
Old Post
Laurent Bossavit
01-03-05 01:56 AM


Re: Newbie question : how to test random functionnalities...
Emmanuel Champommier wrote:

> In order to try "test-driven programming", I wanted to implement some
> statistical functions. Normal law, Binomial law...
> First of all, I should write tests for this function and then... How can I
> test functions which are aimed to send random results ? May I send to test
> functions "pseudo-random" numbers and see if the result is conform to what
I
> expected ?
>
> Thks for your answers and happy new year,

Mock Object-a test fixture passed into the tested code as a placeholder for
a Production Code object. Mock methods log what the calling code does to
them, and return prefabricated values. Use a Mock to test.

* what time is it
* releasing resources
* pseudo-random numbers
* without excessive side effects (such as MessageBox())
* expensive or slow hardware
* modules that depend on modules that don't exist yet, which you can't start
* 3rd party modules that can't Get everything they Set
* threads, semaphores, and other asynchronicities
* responses to failing system calls.

--
Phlip
http://industrialxp.org/community/b...tUserInterfaces



Report this thread to moderator Post Follow-up to this message
Old Post
Phlip
01-03-05 01:56 AM


Re: Newbie question : how to test random functionnalities...
Laurent Bossavit wrote:

> Emmanuel,
> 
>
> Try asking the same question on the French XP mailing list as well:
>   http://fr.groups.yahoo.com/group/xp-france/

/No! Il ne marche pas! Les Francais sont plus resistant de ... logique!/

(Sorry, LB, but you could go hold Americans up as a paragon of
rationality...;)

--
Phlip
http://industrialxp.org/community/b...tUserInterfaces



Report this thread to moderator Post Follow-up to this message
Old Post
Phlip
01-03-05 01:56 AM


Re: Newbie question : how to test random functionnalities...
"Emmanuel Champommier" <champommier@noos.fr> writes:

> In order to try "test-driven programming", I wanted to implement some
> statistical functions. Normal law, Binomial law...
> First of all, I should write tests for this function and then... How can I
> test functions which are aimed to send random results ? May I send to test
> functions "pseudo-random" numbers and see if the result is conform to what
 I
> expected ?

This may not be the best place to start.

It's not clear to me how the "baby-steps" aspect of TDD
comes into play when your just implementing a well-known
algorithm. The tests I'd write for something like this
are a lot closer to acceptance tests than unit tests. A
simple example:

public class RandomTest extends junit.framework.TestCase {

int trials = 10000;
float acceptableError = .01;

public void testBernoulli() {
float p = 0.5;
RandomGenerator bg = new BernoulliGenerator(p);
int counter = 0;
for (int i=0;i<trials;++i) {
counter += bg.next();
}

assertEquals(0,(counter/trials)-p, acceptableError);
}
}

(Is it obvious to everyone that this code was only
written, and not compiled? Good.)

Actually, though, now that I write down this example,
I want factor out the p variable, and start writing
tests for a couple of different values of p...closer
to unit tests after all.

I'm not sure whether I've cleared anything up or not.
You tell me.

--
Mark Jeffcoat
Austin, TX

Report this thread to moderator Post Follow-up to this message
Old Post
Mark Jeffcoat
01-07-05 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Extreme Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:37 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.