Transistors and the like is simple to test, you do a basic function test. Apply eg 30v to collector, measure current after 1us, if the current is under 2 LSB then pass. Then apply 10uA to base, check collector voltage, with current limit of 1mA, is under 5V then pass. 2 checks, gives a good confidence the transistor has both no leakage and some gain. Otherwise any test fail then put the red dot of death on it. If you are binning them for gain groups, then after moulding you simply do the gain test again, and use a comparator and a resistive load to sort into the typical 3 bins of sub 100, 150 to 300 and over 250 bins. The overlap is simply because you will have devices that are close to the edges, so rather put them in a lower bin instead, so the higher value parts are not going to be rejected for suboptimal gain at the customer incoming QC verification. Unsorted parts are then either the whole batch or those that were not the desired gain grouping, giving some interesting spreads on the parts. You saw that with the resistors Dave tested a reel of, where there was a gap in the middle where the close tolerance parts were selected out of the run, leaving the outliers only.
The rest of the type tests are sampled, not production line things, done on a random selection off the final part, typically the first few out the moulding and the last few. As the transistor dies are very often using the same mask sets for many transistors, with the only difference being things like gain, voltage rating and the actual package used, you often find a die that had the single 5 on die tests that were used to determine what transistor they were going to be ( one per quadrant, one in the middle, do a breakdown voltage test and actual gain taking sub 2 seconds per device, then select the generic ATE pattern of 10 per second for the rest) then it is marked as appropriate, or they just mark the whole lot with the desired lower rated part number and let it go at that.
Thus you find transistors with Vceo max of 30V that actually will all break down only over 120V, as this is larger, but the die was not scheduled for the higher voltage part, or it was uncut inventory and an order for the lower part was needed, and using the stock wafer was an easy way rather than an unscheduled run. Tthey just make the stock up later, adding to the end of the line schedules for a run of the wafers. That way the silicon fab is always busy, and they always have stock of the cheap low cost parts.
Diodes the same, just a per wafer reverse voltage test, then a single forward conduction test, a reverse leakage test at some value, and slice and package the working ones. Or even just do no test, and check the final product only, with a line which has had a long run, and where the quality control has enough confidence in the stability of the line to be confident they all will work. that then only means a sample check on breakdown, and a single forward conduction test on all to see they were packaged correctly. You rely on the QC history of the line, and the incoming material non variability as part of the process, so the result is the same wafer after wafer.
The voltage marking is either the binning, or more likely with diodes a per order mark, if the customer wants a 1N4001 you simply mark the 1N4007 parts you know the line always makes with the 1N4001 and send out, or you have a wafer on hand which is not 1N4007 breakdown and use that.
Parts you are going to obsolete, and price increasing, is simple. You have a 5 year supply of wafers in stock, and the line is going to close, so you have already told the large volume purchasers the part is going EOL, and have done the last final buys for them, and are saving the last batches of wafers for the announcement of EOL to the smaller markets, where the volume will use up that last batch in the ordering for them, making you a nice profit on the line as it is closing out.