How do we test and determine if a USB cable+connector is version 2, 3.0 or 3.1?
This is an interesting problem, as there are now a proliferation of similar-looking cable types with the introduction of USB 3.x and the Type C connector. Determining how many pairs are connected, and if it supports flip-over and other compliance issues is non-trivial. There's a lot of mis-marked junk out there and having a reliable way to sort it out would be useful.

Have a look here to see how dire the situation really is: https://www.engadget.com/2016/02/03/benson-leung-chromebook-pixel-usb-type-c-test/

I'm going to assume you're interested in testing USB C cables, since it's possible to suss out previous USB 2.0 vs. 3.x types by the connectors types they have on them. Then again, a test for these non-C cables might be useful too. If you work out a test for Type C, the others are subsets.

Start by getting the actual USB 3.2 spec from USB-IF, here: https://www.usb.org/document-library/usb-32-specification-released-september-22-2017-and-ecns

As a basic test, using a breakout board at each end and checking end-to-end with a multimeter would be the way to do it. You would check for continuity on each possible signal pair:


USB 2.0: DM/DP
USB '3.0 / 3.1' (one SS pair): DM/DP, SSTX+/SSTX-, SSRX+/SSRX-
USB 3.2 Gen 2 (two SS pairs):  DM/DP, SSTX1+/SSTX1-, SSRX1+/SSRX1-, SSTX2+/SSTX2-, SSRX2+/SSRX2-


As an improvement you could use a TDR reflection method, like some LAN cable testers use. This would also tell you if the cable is the right impedance.

More about TDR testing here: https://www.electronics-notes.com/articles/test-methods/time-domain-reflectometer-tdr/what-is-a-tdr.php

Example LAN cable tester here: https://www.cablestogo.com/product/39002/lansmart-tdr-cable-tester

Certifcation-level testing here: https://www.keysight.com/upload/cmc_upload/All/USB_3_0_test_solution_overview.pdf

If you're thinking to make a product I think making a continuity tester board would be useful. The tester would terminate the cable at one end, and test for continuity at the other using a microcontroller to measure it. This would be able to reliably distinguish if the cable has the right number of of pairs. 

Example commercial USB test product: https://www.totalphase.com/blog/2018/09/tools-can-use-test-analyze-functions-power-delivery-usb-type-c-cables/

It would be good to also check shield continuity as a separate test. It's supposed to be isolated from signal ground, but still present, and it's an area where many shoddy vendors will cheat.

(To the other posters - think about how you would do incoming inspection / acceptance on cables you bought for your product. You'd do something like this, and maybe even take the cable apart too.)