The Prophet ﷺ said, "Write down for me the names of all those who have declared Islam." So we recorded fifteen hundred men for him. We said, "Should we fear, when we number fifteen hundred?" Yet I saw us afterward so afflicted that a man would pray alone, gripped by fear.
قال النبي ﷺ: اكتبوا لي من تلفظ بالإسلام من الناس، فكتبنا له ألفا وخمسمائة رجل، فقلنا: نخاف ونحن ألف وخمسمائة! فلقد رأيتنا ابتلينا حتى إن الرجل ليصلي وحده وهو خائف.
Bukhari narrated it in the Book of Jihad (3060) from Muhammad bin Yusuf, who said, our teacher Sufyan told us, from Amash, from Abu Waail, from Huzaifa, and he related it. Muslim also narrated it in the Book of Faith (149) through another route, from Abu Muawiya, from Amash with his chain of transmission, and in it, the Messenger of Allah ﷺ said, "Count for me how many pronounce Islam." So we said, "O Messenger of Allah, do you fear for us when we number between six hundred and seven hundred?" He said, "You do not know, perhaps you will be tested." He said, so we were tested, until a man among us would only pray in secret.Abu Muawiya differed from Thawri, saying, "Between six hundred and seven hundred." Bukhari gave preference to Thawri's narration because he was, without qualification, the more reliable of the two in memorization and he added details beyond what the others reported. As for Abu Muawiya, although he was the most reliable in memorization among the companions of Amash, and Muslim relied on his narration, he did not state the number with certainty. Bukhari therefore gave precedence to Thawri's narration because of its additional detail and its certainty.As for the statement, "we were tested, so a man would only pray in secret," this perhaps occurred during some of the civil strife that took place after the Prophet ﷺ, when some people would conceal themselves and pray in secret out of fear of being exposed and of being drawn into taking part in the strife and the wars. This is what Nawawi said in his commentary on Sahih Muslim.