Mathieu Schepens wrote:
As students of Master 2 IAGL from Lille 1 university (France), four of
us are asked to develop some tests around an open-source project.
Among proposed projects, we decided to contribute to Pharo.
We'll have to develop 15-20tests
(isolated/automated/reproducible/quick/good code coverage), and we are
wanting them to be as much useful as possible for developers.
Where (in the project) could it be useful to develop some tests ? Do
you have advices/instructions for us in order to develop them ?
We are new with Pharo and Smalltalk, and are having about 8-10hours
available per developer.
Best regards,
Mathieu Schepens
Thanks for your consideration of Pharo. Now we should properly
understand your time constraints. So...
* What is your experience with Pharo?
* How comfortable are you with the syntax, Browser and Debugger?
* Have you used the TestRunner previously?
* Have you submitted a code Slice for integration before?
In a lot of areas, a lot of background knowledge is required to writing
useful tests, which you obviously can't gain in your allocated time.
However every additional test increasing coverage is useful. However
even more use than these individual tests is that you have a good
experience with Pharo, to hopefully see you back here later are this
course requirement is done. (Careful, Pharo is addictive). So to be
pragmatic, I suggest a good starting point is a widely understood domain
like strings. I'll give you an example of how to discover some coverage
gaps yourself.
FINDING GAPS
1. Open World menu > Tools > Finder
2. From its pulldown menu which says "Selectors" choose "Examples"
3. Now imagine some kind of string function you are familiar with...
What are the parameters and what is the result? For example, imagine a
function to might give you the first N characters of a String. For two
parameters 'abcd' and 2, the result would be 'ab'. Now in the text box
on the left side, type those three items separated by a dot. For
example... 'abcd' . 2 . 'ab'
4. Press the <Search> button, and you will see three results. Using
"contractTo:" as an example, navigate to view its code. In that code
select the text "contractTo:", right-click and choose "Extended
search... > senders of it". The list that comes up shows a class on the
left and on the right the method that calls "contractTo". Now you will
notice that none of the classes include the name "Test". Ah-Haaa!! A gap
to fill :)
DEFINING TESTS
1. Open Spotlight in the top right by pressing CMD-SPACE (on a Mac,
other platforms have a different key modifier)
2. Enter... StringTest
which should open a Browser on the StringTest class
3. Just for practice, click on the little circle next to the method
names to run that test method. Right-click on the test and choose
"Debug" to step through the test.
4. Review the other existing tests and replicate for you own tests for
methods found that have a gap in coverage.
SUBMISSION AND INTEGRATION
Once you have your new tests working you should get a login to the Pharo
issue tracker at http://pharo.fogbugz.com create a ticket, and
submit a "Slice" with your changes for review and integration. (btw,
right now I am heading off to bed so others will follow up further
questions).
good luck, cheers -ben