In order to design a nuclear weapon, it is necessary to mathematically model the processes that lead to the explosion. The device is then simulated on a computer. In fact, a large amount of computing is required. Several assumptions go into the modeling and one cannot be absolutely sure how accurate the model is without actually testing it.
The more complicated the design, the less reliable the modeling and the more the testing required. Thus the simple “gun assembly” design (used in the Hiroshima bomb) does not require testing. It is generally felt that an implosion device needs to be tested (as was done for the Nagasaki bomb).
Apart from a full scale test of the weapon, several other tests are done to check different aspects of the device and the mathematical modeling.
Hydrodynamic tests: These are tests which do not use fissile material (an inert material with similar properties is substituted). These tests could, for example, be used to determine how well the conventional explosives in an implosion design work. Such tests are not banned by the Comprehensive Test Ban Treaty (CTBT)
An underground nuclear explosion shakes the ground as much as an earthquake does. Thus the shock produced by the explosions causes vibrations of the earth which can be detected far away by seismic stations which monitor earthquakes. The signal produced by a nuclear explosion can be clearly distinguished from that produced by earthquakes.
There is now a network of seismic stations all over the world which are constantly monitoring the vibrations of the ground. Thus any underground explosion of a significant strength will get detected. The yield of the explosion can also be estimated from the signal but this measurement is not very accurate.