Servo sweeps once and stops

I have uploaded the following programme to my Ardunio uno from the Ardunio website to run a servo (Tower Pro SG90)

#include <Servo.h>

Servo myservo; 

int pos = 0;   
#include <Servo.h>             //Servo library
 
Servo servo_test;        //initialize a servo object for the connected servo  
                
int angle = 0;    
 
void setup() 
{ 
  servo_test.attach(9);      // attach the signal pin of servo to pin9 of arduino
} 
  
void loop() 
{ 
  for(angle = 0; angle < 180; angle += 1)    // command to move from 0 degrees to 180 degrees 
  {                                  
    servo_test.write(angle);                 //command to rotate the servo to the specified angle
    delay(15);                       
  } 
 
  delay(1000);
  
  for(angle = 180; angle>=1; angle-=5)     // command to move from 180 degrees to 0 degrees 
  {                                
    servo_test.write(angle);              //command to rotate the servo to the specified angle
    delay(5);                       
  } 

    delay(1000);
}

When I plugged in the control link the servo moved once and stopped. I tried reloading the programme but nothing happened at all. I tried a second servo and the same thing happened. I have tested a third servo on a small commercial servo test module and this works fine. I have tested the first two servos on this tester and nothing happens. I am reluctant to try the third servo with the Ardunio in case this too stops after one sweep. Is there anything wrong with my programme that is causing this fault?

Is there anything wrong with my programme that is causing this fault?

No. The code is fine. The problem must have to do with how you are wiring the servo.

On Arduino from servo: '+' wire to 5v, '-' wire to ground, Control wire to pin 9. From test Module: the same but control wire not connected to Ardunio. Works fine in all three modes.

On Arduino from servo: '+' wire to 5v, '-' wire to ground

You shouldn't be trying to power a servo from the Arduino. Servos draw way too much current.

PaulS: You shouldn't be trying to power a servo from the Arduino.

Alas, and in OP's defence, the example does it that way.