“And a believing man from the family of Pharaoh who concealed his faith said, “Do you kill a man [merely] because he says, ‘My Lord is Allah ‘ while he has brought you clear proofs from your Lord? And if he should be lying, then upon him is [the consequence of] his lie; but if he should be truthful, there will strike you some of what he promises you. Indeed, Allah does not guide one who is a transgressor and a liar.” – Qur’an 40:28
The above verse has been cited by critics that the passage encourages deception. A careful reading of the verse shows that there is nothing in the verse of such encouragement. When we read the verse, it says that there was a family member of Pharaoh who was a believer who concealed his faith.
How is that deception? I mean, if the case was that someone asked him what his religion was and he said contrary to what he believed inside his heart, then we can say it is deception. But there is nothing of such. Hence, no deception was used by the believer.
Commentary on Quran 40:28
Ma’arifulul-Qur’an – Maulana Muhammad Shaffi
In verse 28, it was said: … (who had kept his faith secret). This tells us that a person who does not declare his Iman (faith) before people, yet remains staunch in his heart, then this person is a believer. But, it stands proved from clear textual authority (of the Qur’an and Hadith) that, for Iman to be acceptable, the simple certitude of the heart is not enough, instead, it is subject to the condition of verbal confession and declaration. Unless the person concerned declares it verbally, he or she will not as a believer.
However, making this verbal declaration before people publicly is not necessary. The only reason why it is needed is that unless people come to know about the person’s iman, they would remain unable to interact with him or her in the same way as they do with Muslims. (Qurtubi)
Earlier in the verse, by saying: … (a believing man from the House of the Pharaoh), it is virtually demonstrated that the believer, in his ensuing dialogue with Pharaoh and his people, invited them toward truth and faith as well as restrained them from killing Sayyidna Musa (Moses). 
 Ma’arifulul-Qur’an By Maulana Muhammad Shaffi, volume 7, page 602