Here is one of the examples from the Adafruit Motor Shield Library:
https://github.com/adafruit/Adafruit-Motor-Shield-library/blob/master/examples/MotorTest/MotorTest.pde
You will need to download and install the Adafruit Motor Shield Library:
I have used this example with my Motor Shield and it works as advertised.