Vinyl test pressings are made to test the sound quality of the stampers; to make sure they are free of errors such as pops and clicks, dropouts, skips, and that they sound as intended, as the cutting process does have some impact on the sound. Obviously, they are pressed using the same stampers which will press the retail albums, so they will always have the same matrix codes as the retail pressing, unless the cut was rejected. Test pressings are usually pressed about one month ahead of release date and in very limited quantities, often no more than ten. They usually come with white labels or with generic pressing plant labels. Catalog numbers, dates, titles, and more may be handwritten or stamped on the labels or the inner sleeve. The text may have been written by the pressing plant, the record label, the distributor, by the original recipient, or by a collector. If the text is similar on several copies, the text is most likely written by any of the companies involved.
Test pressings are inspected visually and played at the pressing plant. They may be sent to the cutting engineer, the band or their management, the producer, and the record label A&R person for approval. Remaining test pressings at the pressing plant may be recycled.
Sometimes record labels, mostly smaller, independent labels, also used test pressings to presell the release to retailers by physically bringing them into the shops . Some have also been used for regular radio or press promotion, such as some copies of Love Buzz and Oh, The Guilt. In both these cases they may come with press releases or other printed information, or come in generic record label or distributor sleeves.
In theory, test pressings should exist for every vinyl release available. However, hardly any Geffen/DGC test pressings have been found. The main reason is probably that the independent labels often used them as promos and sent them around to people involved with the recording, so they ended up in various places, later to be sold in auctions and similar. Major labels make custom promos in large numbers, so this is not necessary for them. Most of their test pressings probably never left the pressing plants or record label offices, and were instead recycled. It is also possible that several test pressings were pressed using retail labels.
As test pressings are the very first records to be made with brand new stampers, it would perhaps be reasonable to think that they are the best sounding records possible of that release. This may not always be the case, as they may contain test pressing noise which is caused by noise artefacts on new stampers. The first 20-50 copies from a pair of stampers during a retail press run are often discarded because it takes that many copies to get rid of the noise artefacts.  How this is practiced by the various pressing plants probably varies a lot.
During pressing, records are periodically picked out and played back for quality control. Any degradation is a sign that the stampers are wearing out and must be replaced.  As these records are pressed with regular labels, there is no way to identify them.
Test pressings are usually pressed on black vinyl, even though the retail records will be on colored vinyl or picture discs. Pressing regular black vinyl test pressings tests the audio quality of the stampers just as well.  The hopper and extruder in the machine making the biscuits are usually running black vinyl as standard, so additional time is required to clean them if changing color, which nobody would do for a short run of test pressings. [2,4] Black vinyl is simply cheapest and most readily available.
Some Nirvana test pressings on colored vinyl exist, such as the pink and white Bleach test pressings made in the USA and the UK, respectively. The pink test pressings were probably just done using a color which was available in a hopper at the time, while the white test pressings seem to have directly preceeded the retail pressing and worked as a final cleaning of the extruder. The most elaborate colored test pressing is the Hormoaning EP. In this case, the two colors seem to have come from two different hoppers and put together by hand. The test pressings of this record may have been made to test both the audio and colors at the same time, but it is more likely that it was (one of) the first record(s) off the press just before adding proper labels for the retail pressing, similar to the white Bleach.
Some have said that setting up the press to make a short run of picture disc test pressings is expensive for the pressing plant , presumable because it requires more time, but regular vinyl and picture discs do not really have different setups even though they are made a little differently . Picture discs and test pressings are made on manual presses, one record can be on black vinyl and the next can be a picture disc , though with picture discs more materials have to be handled; the two paper pictures and three layers of vinyl. It will require more time if an extruder has to be cleaned for the clear vinyl, though, so if there is no extruder already running clear vinyl that would incur additional expenses.
In any case, it is completely unnecessary to gather clear vinyl and pictures just for a test pressing. It is simply easier, and probably a little cheaper, to press them on black vinyl. An example of this is the test pressing of the Australian Oh, The Guilt picture disc. The test pressing of the British Come As You Are picture disc is the only known Nirvana test pressing to have been done as a picture disc.
Sometimes records appear in unusual and rare color variants, occasionally hyped as "color test pressings". In other words, a test pressing not made to test the audio quality of the stampers, but to see how the color or color mix worked out. These claims are mostly false. They are simply rare colors.
To get multi-color effects on vinyl, colored vinylite pellets are mixed together when they are placed in the hopper, melted, and pushed through an extruder to form the biscuits. It is impossible to guarantee an exact result when colors are mixed this way. You usually get a swirling effect, but other effects can happen. Even so, plants will usually not make test pressings to try out the colors, because to make them you have to empty the hopper of all the existing black vinyl pellets, clean it and the the extruder, and then put in the colors you want. This whole process is too time consuming to only make a few tests, and no pressing plant would do it for less than a minimum 500 pressing quantity, then or now. 
Retail copies with odd colors may exist if the record label hoped for a particular effect. If the result was unsatisfactory, they may have decided not to release it. It is unlikely that any small indy label would do that, because they would have to absorb the cost of the manufacture. Major labels apparently do this often. 
Another possibility for the existence of odd colors is that a pressing plant keeps a variety of colored and mixed-colored vinyl samples that they can show to customers who are interested in having a colored vinyl or picture disc pressing made. The pressing plants will invariably use random stampers and labels to make these samples, basically whatever was lying around when they had some spare time and an empty hopper. 
Yet another possibility is that throughout history, when having a free, unsupervised moment, pressing plant workers have taken it upon themselves to make rare custom records and taken them home. These records can be made on unusual one-off colors, or having mixed up labels with other releases.
CD test pressings aren't strictly necessary. A person reported that nobody had asked for a CD test pressing during all of his 15 years working in CD replication. The stampers can be tested on a signal analysis machine, which performs data verification system (DVS) tests and signal verification tests. The DVS tests compare the data to the image ready master bit for bit, and the signal verification tests check that the playback parameters are whithin specification. The same tests are also performed on the pressed discs sampled at various times during the pressing process, especially with long press runs. The tests are digital and fast, so nobody will have to listen to the discs to approve them.  As such, while the first disc pressed is most likely tested, it is not an advance, dedicated test pressing (unless requested by the record label which rarely happens), but pressed as a part of the retail pressing.
These discs are usually taken out of the production line just before they are to be printed, so they have no artwork. However, some plants print a custom pressing plant "sample" or "test pressing" design on the discs. These discs are often sent to the record labels where they are used internally, probably by the product manager and the sales team, or sent to distributors and other partners. They may have been used for regular promotion occasionally, but that is probably rare bacause the discs are quite limited.
There is a possibility that some sample discs may have been printed with custom promo labels and used for regular promotion. In this case more samples, or rather, unprinted discs, may have been picked from the line than usual, but not necessarily. The Canadian advance promo of From The Muddy Banks Of The Wishkah (DGCD 9687) is a strong contender. While they have a custom catalog number which is indicative of a custom pressed promo, the matrix code shows that they are the same discs as those from the retail pressing.