Coronal rain consists of cool and dense plasma condensations formed in coronal loops as a result of thermal instability. Previous numerical simulations of thermal instability and coronal rain formation have relied on artificially adding a coronal heating term to the energy equation. To reproduce large-scale characteristics of the corona, using more realistic coronal heating prescription is necessary. We analyse coronal rain formation and evolution in a 3-dimensional radiative magnetohydrodynamic simulation spanning from convection zone to corona which is self-consistently heated by magnetic field braiding as a result of convective motions. We investigate the spatial and temporal evolution of energy dissipation along coronal loops which become thermally unstable. Ohmic dissipation in the model leads to the heating events capable of inducing sufficient chromospheric evaporation into the loop to trigger thermal instability and condensation formation. The cooling of the thermally unstable plasma occurs on timescales comparable to the duration of the individual impulsive heating events. The impulsive heating has sufficient duration to trigger thermal instability in the loop but does not last long enough to lead to coronal rain limit cycles. We show that condensations can either survive and fall into the chromosphere or be destroyed by strong bursts of Joule heating associated with a magnetic reconnection events. In addition, we find that condensations can also form along open magnetic field lines.