It depends on the strength of his faith and the quality of his faith and he can’t be dictated from outside. It’s an inner compulsion which dictates terms to him and the Holy Qur’an mentions both these, both type of people who are brave enough to suffer everything, to go through the trial of death smilingly and they don’t care.
Those are referred to as shahada and there are those who are saliheen who also suffer all their lives but they never hide their faith, in fact they go out and preach to others. So a society which is created for inviting the whole mankind or a tribe in the olden days to the path of God, how can they think of hiding their faith? I mean they are contradictory things. You can’t preach as well as hide.
So you are expected not only to disclose your identity but also to go out and invite others to the same way of life and the same trials which you are going through. So that is not an easy job that requires a man to become a believer and to fulfill all the obligations.