If the first mode is chosen and the target card is an illegal target as Test of Courage tries to resolve, it won't resolve and none of its effects will happen. You won't gain life.

Artwork
Loading artwork…
Test of Courage
Star Trek · #220 · EN
Nonfoil—Foil—
Card rules
Choose one —
• Alter the Past — Exile target card from a graveyard. You gain 2 life.
• Obliterate the Transwarp Network — Destroy target artifact or enchantment with mana value 3 or less.
"Sorry to surprise you. Next time we'll call ahead." —Captain Kathryn Janeway
Uncommon · Illustrated by Zoltan Boros
Format legality
Brawl Legal
Commander Legal
Competitive Brawl Legal
Duel Legal
Future Legal
Gladiator Legal
Historic Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Penny Legal
Pioneer Legal
Standard Legal
Standard Brawl Legal
Timeless Legal
Tlr Legal
Vintage Legal
Alchemy Not Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
PreDH Not Legal
Premodern Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
If a permanent has X in its mana cost, X is 0 for the purpose of determining its mana value.