To obtain a pilot's license and at many times during a pilot's career, they will be required to pass regular proficiency exams known as 'checkrides' to continue flying. Checkrides are a staple of the aviation industry and are conducted to assess a pilot's ability to maintain control of an aircraft during emergencies as well as keep it within structural limits and speed restrictions.
Checkrides test a pilot's knowledge in many aspects. Do they know what to do in the event of an engine failure? Do they know what to do if the cabin loses pressure? Checkrides will determine this, and are given frequently .
As far as airlines go, checkrides usually consist of an entire morning in a room discussing aircraft performance characteristics as well as changes to avionics and other aircraft systems, usually ended with a written exam, after which many hours are spent inside a simulator with an instructor.
During these simulator sessions, the instructor will sit behind the pilot (or pilots as the case was when I was an observer) at a panel that they can use to cause every conceivable problem that a pilot may encounter during the course of a flight from wind shear to turbulence to loss of an engine. The instructor will observe the pilots' actions and grade them based on performance. The instructor also notes whether or not the pilots are staying within the design specifications of the aircraft (i.e. not overspeeding the aircraft, too steep ascent/descent rates, correct V-speeds) as well as whether the pilots are adhering to FAA regulations such as staying below 250 knots below 10,000 feet.
During the course of one of these simulator checkrides, the pilots start off at an airport gate and complete an entire flight in real time, after which the instructor will discuss any errors made and possibly have the pilots re-fly part of the flight to strengthen and reinforce any weak areas. The instructor will then sign off on the pilot(s), which means that they are now ready to continue to fly.
In the general aviation world, the instructor will sit alongside the pilot and give the pilot performing the checkride a set of circumstances that they must adhere to in order to pass the exam. Since in a real aircraft it is not practical or safe to shut down an engine and it's not quite possible to simulate weather conditions, the instructor will tell the pilot fly a predetermined route and maintain a certain heading and altitude while keeping the aircraft with a certain tolerance (usually within 5 degrees +/- the given heading and within 50-100 feet of the altitude). The instructor will monitor the aircraft systems and grade the pilot on everything from correct aircraft procedures to FAA regulations as well as how well the aircraft is flown and handled on the ground.
After the checkride is completed, the instructor will pass or fail the pilot. If the pilot is a student, they will not receive their license until the successful completion of a checkride. A checkride is also required to renew a pilot's license, which is mandatory every two years.