How can I test for a player wearing specific armor?

Solution 1:

Although you can't set player data with commands, you can test for it, in your example it's like this:

/execute as @p[nbt={Inventory:[{Slot:103b,id:"minecraft:iron_helmet",tag:{display:{Name:"{\"text\":\"test1\"}"}}},{Slot:102b,id:"minecraft:iron_chestplate",tag:{display:{Name:"{\"text\":\"test2\"}"}}}]}] run <command>