This is a common backyard mechanic technique to test if your alternator is working properly. In theory, if your alternator is providing adequate power to the car while charging the battery, then once the car is started, disconnecting the battery should not cause the engine to stop running. If it does, then there is a possibility that the alternator is not producing enough electricity, or a connection to it is either not working or it is only working intermittently. HOWEVER, be aware that this test is not without risk to damaged car electronics.
If your alternator is malfunctioning by over-charging your battery, disconnecting it may allow the alternator to provide an even higher voltage to the car electronics, and potentially damage those sensitive components. Also, if the alternator is providing power intermittently, it may cause the computer lock up and produce other problems. Therefore, this test is safest if not performed at all. You are better to use a voltmeter, and measure the voltage at the battery when the car is off and when it’s running. In simple terms, if the voltage is higher when the car is running, then the alternator is providing at least some energy back to the battery, but that doesn’t mean that it’s working optimally. Get it tested if you believe there is a problem.