Caurie Swinger was testifying in a New Jersey murder case when sheriff's officers saw him on his phone.

A US man testifying that he saw two men open fire before a 12-year-old girl was killed was caught texting from the witness stand.

Caurie Swinger was testifying in the case of two New Jersey men charged in Genesis Rincon's murder on Wednesday morning (NZT) when sheriff's officers saw him on his phone, The Record reports.

Judge Scott Bennion ruled that defense attorneys for Jhymiere Moore and Jeffrey Ellerbee can cross-examine Swinger about his texting from the witness stand. The trial will resume on Thursday (NZT).

It wasn't immediately clear what Swinger was texting.

Genesis was struck in the head in July 2014 as she rode to a family gathering in Paterson. She was not the intended victim of what prosecutors say was an ongoing feud between rival gangs.

Swinger testified that Moore and Ellerbee fired about eight shots at the van and then fled along with Marshae Anthony, who faces weapons charges. Swinger said he recognized the men because he knew them for years.

Swinger is awaiting sentencing after pleading guilty to animal cruelty and drug charges In September. He was charged in 2014 for running a large-scale dogfighting ring in Paterson.