The appeal presents this question for decision: Does the pendency of a prior action by the wife for a divorce from bed and board upon the ground of abandonment abate a subsequent action by the husband for an absolute divorce upon the ground of two years’ -separation ?
The pendency of a prior action between the same parties for the same cause in a State court of competent jurisdiction works in abatement of a subsequent action either in the same court or in another court of the State having like jurisdiction. Seawell v. Purvis, 232 N.C. 194, 59 S.E. 2d *85572; Taylor v. Schaub, 225 N.C. 134, 33 S.E. 2d 658; Moore v. Moore, 224 N.C. 552, 31 S.E. 2d 690; Brown v. Polk, 201 N.C. 375, 160 S.E. 357; Bank v. Broadhurst, 197 N.C. 365, 148 S.E. 452; Underwood v. Dooley, 197 N.C. 100, 147 S.E. 686; 64 A.L.R. 656; Morrison v. Lewis, 197 N.C. 79, 147 S.E. 729; Bradshaw v. Bank, 175 N.C. 21, 94 S.E. 674; Pettigrew v. McCoin, 165 N.C. 472, 81 S.E. 701, 52 L.R.A. (N.S.) 79; McNeill v. Currie, 117 N.C. 341, 23 S.E. 216; Long v. Jarratt, 94 N.C. 443; Smith v. Moore, 79 N.C. 82; Claywell v. Sudderth, 77 N.C. 287; Harris v. Johnson, 65 N.C. 478. It is immaterial that tbe parties, plaintiff and defendant, are reversed in tbe two actions. Brothers v. Bakeries, 231 N.C. 428, 57 S.E. 2d 317; Crouse v. York, 192 N.C. 824, 135 S.E. 451; Emry v. Chappell, 148 N.C. 327, 62 S.E. 411.
Tbe ordinary test for determining whether or not tbe parties and causes are tbe same for tbe purpose of abatement by reason of tbe pend-ency of tbe prior action is this : Do tbe two actions' present a substantial identity as to parties, subject matter, issues involved, and relief demanded? Whitehurst v. Hinton, 230 N.C. 16, 51 S.E. 2d 899; Lumber Co. v. Wilson, 222 N.C. 87, 21 S.E. 2d 893; Redfearn v. Austin, 88 N.C. 413; Casey v. Harrison, 13 N.C. 244. This test lends itself to ready application where both actions are brought by tbe same plaintiff against tbe same defendant, or where tbe plaintiff in tbe second action, as defendant in tbe first, has actually pleaded a counterclaim or cross demand for tbe same cause of action.
Tbe ordinary test of identity of parties and causes is not appropriate, however, when'the parties to tbe prior action appear in tbe subsequent action in reverse order, and tbe plaintiff in tbe second action, as defendant in tbe first, has failed to plead a counterclaim or cross demand for tbe same cause of action. Under tbe law, a defendant, who has a claim available by way of counterclaim or cross demand, has an election to plead it as such in tbe original action, or to reserve it for a future independent action, unless tbe claim is essentially a part of tbe original action and will necessarily be adjudicated by tbe judgment in it. Bell v. Machine Co., 150 N.C. 111, 63 S.E. 680; Shakespeare v. Land Co., 144 N.C. 516, 57 S.E. 213; Mauney v. Hamilton, 132 N.C. 303, 43 S.E. 903; Shankle v. Whitley, 131 N.C. 168, 42 S.E. 574. As a consequence, tbe general rule is that a subsequent action is not abatable on tbe ground that tbe plaintiff therein might obtain tbe same relief by a counterclaim or cross demand in a prior action pending against him. Trust Co. v. McKinne, 179 N.C. 328, 102 S.E. 385; Blackwell Mfg. Co. v. McElwee, 94 N.C. 425; Woody v. Jordan, 69 N.C. 189.
In tbe very nature of things, however, this general rule is not applicable where tbe cause of action asserted by plaintiff in tbe second action is essentially a part of tbe first action and will necessarily be adjudicated by tbe judgment in it. 1 C.J.S., Abatement and Eevival, *86section 43 C. For these reasons, the law devises a special test of identity of parties and causes where the parties to the prior action appear in the subsequent action in reverse order and the plaintiff in the second action, as defendant in the first, has failed to plead a counterclaim or cross demand for the same cause of action. In such case, the pendency of the prior action abates the subsequent action when, and only when, these two conditions concur: (1) The plaintiff in the second action can obtain the same relief by a counterclaim or cross demand in the prior action pending against him; and (2) a judgment on the merits in favor of the opposing party in the prior action will operate as a bar to the plaintiff’s prosecution of the subsequent action. Brothers v. Bakeries, supra; Reece v. Reece, 231 N.C. 321, 56 S.E. 2d 641; Dwiggins v. Bus Co., 230 N.C. 234, 52 S.E. 2d 892; Johnson v. Smith, 215 N.C. 322, 1 S.E. 2d 234; Allen v. Salley, 179 N.C. 147, 101 S.E. 545; Emry v. Chappell, supra; Alexander v. Norwood, 118 N.C. 381, 24 S.E. 119; Gray v. A. & N. C. R. R. Co., 77 N.C. 299.
These things being true, the primary question raised by the appeal necessarily embraces the subsidiary inquiries whether Cameron can obtain the relief sought by him in the subsequent action in New Hanover County by a counterclaim or cross demand in the prior action pending against him in Sampson County, and whether a judgment on the merits in favor of Mrs. Cameron in the prior action in Sampson County will operate as a bar to Cameron’s prosecution of the subsequent action in New Hanover County.
It is well settled that in an action for divorce, either absolute or from bed and board, it is permissible for the defendant to set up a cause of action for divorce, either absolute or from bed and board, as a counterclaim or cross demand. Lockhart v. Lockhart, 223 N.C. 559, 27 S.E. 2d 444; Shore v. Shore, 220 N.C. 802, 18 S.E. 2d 353; Ellis v. Ellis, 190 N.C. 418, 130 S.E. 7. Such counterclaim or cross demand may even be based, in whole or in part, upon facts occurring after the institution of the action. Pettigrew v. Pettigrew, 172 Ark. 647, 291 S.W. 90; Von Bernuth v. Von Bernuth, 76 N.J. Eq. 487, 74 A. 700, 139 Am. S. R. 784; Weiss v. Weiss, 135 Misc. 264, 238 N.Y.S. 36; Ames v. Ames, 109 Misc. 161, 178 N.Y.S. 177; Roberts v. Roberts, 99 W. Va. 204, 128 S.E. 144; Martin v. Martin, 33 W. Va. 695, 11 S.E. 12; Heinemann v. Heinemann, 202 Wis. 639, 233 N. W. 552. This is true because the statute does not require that a counterclaim must be one existing at the commencement of the plaintiff’s action except in the case of a counterclaim arising out of contract. G.S. 1-137; Smith v. French, 141 N.C. 1, 53 S.E. 435; McIntosh: North Carolina Practice and Procedure in Civil Cases, Section 467. Hence, Cameron can obtain the relief sought by him in the present action by a counterclaim or cross demand in the prior action pending against him in Sampson County.
*87Where the wife sues the husband for a divorce from bed and board upon the ground of abandonment under G.S. 50-7 (1), she must prove as an essential part of her case that her husband has wilfully abandoned her. Brooks v. Brooks, 226 N.C. 280, 37 S.E. 2d 909. Where the husband sues the wife for an absolute divorce upon the ground of two years’ separation under G.S. 50-6, he is not required to establish as a constituent element of his cause of action that he is the injured party. Taylor v. Taylor, 225 N.C. 80, 33 S.E. 2d 492. Nevertheless, the law will not permit him to take advantage of his own wrong. Consequently, the wife may defeat the husband’s action for an absolute divorce under G.S. 50-6 by showing as an affirmative defense that the separation of the parties has been occasioned by the act of the husband in wilfully abandoning her. Taylor v. Taylor, supra; Pharr v. Pharr, 223 N.C. 115, 25 S.E. 2d 471; Byers v. Byers, 223 N.C. 85, 25 S.E. 2d 466; Reynolds v. Reynolds, 208 N.C. 428, 181 S.E. 338. It follows that a judgment on the merits in favor of Mrs. Cameron in the prior action in Sampson County will operate as a bar to Cameron’s prosecution of the subsequent action in New Hanover County. Such judgment will necessarily adjudicate that Cameron has wilfully abandoned Mrs. Cameron.
The conclusion that the pendency of the prior action in Sampson County abates the subsequent action in New Hanover County seems at first blush to be inconsistent with the decision of a divided court in Cook v. Cook, 159 N.C. 46, 74 S.E. 639, 40 L.R.A. (N.S.) 83, Ann. Cas. 1914 A, 1137, where the husband unsuccessfully pleaded the pendency of his prior action for an absolute divorce on the ground of separation for ten successive years in abatement of his wife’s subsequent action for a divorce from bed and board on the ground of wilful abandonment. The supposed inconsistency is apparent and not real. This becomes plain on consideration of later litigation between the same parties reported in Cooke v. Cooke, 164 N.C. 272, 80 S.E. 178, 49 L.R.A. (N.S.) 1034. The majority held that there was no abatement in the Gook case because the substantive law governing the grounds of divorce made the issues in the one case utterly irrelevant to the issues in the other. This holding was a perfectly sound deduction from the premise accepted by the majority, i.e., that the statute invoked by the husband permitted an absolute divorce on the ground of separation for ten successive years irrespective of whether the party seeking the divorce or the other party was to blame for the separation. The validity of the reasoning of the majority respecting the question of abatement has not been impaired by the fact that the court subsequently rejected their premise by holding that an action for an absolute divorce on the ground of separation for ten successive years could only be brought by the injured party. Lee v. Lee, 182 N.C. 61, 108 S.E. 352; Sanderson v. Sanderson, 178 N.C. 339, 100 S.E. 590.
*88If be so desires, Cameron can apply for leave to set up bis alleged cause of action for divorce as a counterclaim or cross demand in tbe action pending against him in tbe Superior Court of Sampson County. Sucb leave would undoubtedly be granted for “right and justice require that an amendment be allowed wbieb will enable tbe parties to end tbe . . . controversy in one and tbe same litigation.” Smith v. French, supra.
For tbe reasons given, tbe judgment overruling tbe plea in abatement and refusing to dismiss tbe action is
JOHNSON, J., took no part in tbe consideration or decision of tbis case.