
534 So.2d 582 (1988)
Ex parte CANAL INSURANCE COMPANY.
In re: Mike SPARKS, et al.
v.
CANAL INSURANCE COMPANY, et al.
87-757.
Supreme Court of Alabama.
September 9, 1988.
Rehearing Denied November 18, 1988.
*583 Tom E. Ellis of Kracke, Thompson & Ellis, Birmingham, for petitioner.
John A. Owens of Phelps, Owens, Jenkins, Gibson & Fowler, Tuscaloosa, for respondents.
SHORES, Justice.
Canal Insurance Company ("Canal") petitions this Court for a writ of mandamus directing the Honorable Clatus K. Junkin, Judge of the Circuit Court of Pickens County, to grant Canal's motion which sought a dismissal or a summary judgment. Alternatively, it asks us to direct the trial judge to stay a suit in the circuit court pending the final resolution of a prior declaratory action filed in the United States District Court, Northern District. Canal also requests that a writ of mandamus issue directing the trial judge to vacate certain discovery orders.
On December 30, 1986, Canal issued an automobile physical damage policy insuring a 1987 Peterbilt tractor, and naming as the insured Mike Sparks. On April 6, 1987, the tractor ran off the road near Vicksburg, Arizona, and sustained damage. The insured had the tractor towed to Tuscaloosa and incurred a substantial towing charge. On May 29, 1987, the insured presented a sworn proof of loss to Canal, claiming $84,000 in damage to the tractor and $5,350 in towing expenses.
On June 1, 1987, Canal demanded that the amount of loss be established pursuant to the appraisal provisions contained in the insurance policy. Canal designated its appraiser and sought agreement of the insured to enter into the appraisal process provided for in the policy. The insured refused to agree to the appraisal process, whereupon, on July 23, 1987, Canal filed the federal action, seeking a determination of its obligations under the policy.
On August 10, 1987, Sparks filed a complaint against Canal in the Circuit Court of Pickens County, setting forth claims based upon an alleged breach of contract, a bad faith refusal to pay a valid claim, the tort of outrage, and fraud. The facts and circumstances alleged in support of his complaint arose out of the issuance of the insurance policy and the proof of loss claim filed with Canal.
On September 14, 1987, Canal filed a motion to dismiss, or, in the alternative, to stay the proceedings in the state court action, asserting that the prior action pending in the federal court barred the state claim, and that the matters asserted in the complaint were properly matters of compulsory counterclaim in the federal action. Fed.R. Civ.P. 13(a).
On November 11, 1987, Sparks filed his answer and counterclaim in the federal action. The federal counterclaim contained the same allegations of fact and the same claims for relief as were asserted in Sparks's state court action.
We are informed in the briefs that the trial judge in the federal court action granted Canal's motion for summary judgment on April 6, 1988, and that on April 26, 1988, Sparks perfected his appeal to the United States Court of Appeals, 11th Circuit.
The action for declaratory judgment was filed in the federal court before the action was filed in the Circuit Court of Pickens *584 County. Exactly the same facts and claims for relief were stated in the state action as in the counterclaim filed in the federal court. Under both the Alabama Rules and the Federal Rules, the counterclaim was a compulsory one.
Rule 13(a), Ala.R.Civ.P., and Rule 13(a), Fed.R.Civ.P., require a party to file as a counterclaim "any claim ... the pleader has against any opposing party" that arises out of the same transaction or occurrence involved in the opposing party's claim. As was stated in Safeco Ins. Co. of America v. Sims, 435 So.2d 1219 (Ala.1983):
"We know of no reason that ARCP 13(a) is not applicable to declaratory judgment actions. The very essence of that prior suit was the adjudication of the rights of the parties with respect to the insurance coverage. The declaratory judgment action was no different from any other proceeding seeking to litigate that issue."
Safeco, supra, at 1222.
Several tests have been suggested for determining whether issues presented are properly compulsory counterclaims under Rule 13(a). Among those tests are:
"(1) Are the issues of fact and law raised by the claim and counterclaim largely the same?
"(2) Would res judicata bar a subsequent suit on defendant's claim absent the compulsory counterclaim rule?
"(3) Will substantially the same evidence support or refute plaintiff's claim as well as defendant's counterclaim?
"(4) Is there any logical relation between the claim and the counterclaim?"
Desroches v. Ryder Truck Rental, Inc., 429 So.2d 1010, 1012 (Ala.1983), citing, 6 C.A. Wright and A.R. Miller, Federal Practice and Procedure, § 1410 at 42.
"While this Court has never specifically adopted a test for determining whether a counterclaim is compulsory, the Committee Comments indicate that it was the intent of the drafters of the rules to adopt the `logical relationship' test. The Committee Comments to Rule 13 state that `[a] counterclaim is compulsory if there is any logical relation of any sort between the original claim and the counterclaim.'
"The Court of Civil Appeals adopted the logical relationship test in O'Donohue v. Citizens Bank, 350 So.2d 1049 (Ala.Civ.App.1977). The logical relationship test denominates a counterclaim as compulsory if (1) its trial in the original action would avoid a substantial duplication of effort or (2) the original claim and the counterclaim arose out of the same aggregate core of operative facts. The claims arise from the same core of operative facts if (1) the facts taken as a whole serve as the basis for both claims or (2) the sum total of facts upon which the original claim rests creates legal rights in a party which would otherwise remain dormant. Id., Revere Copper & Brass, Inc. v. Aetna Casualty and Surety Co., 426 F.2d 709 (5th Cir.1970)."
Brooks v. Peoples Nat. Bank of Huntsville, 414 So.2d 917, 919 (Ala.1982).
Because the matter asserted in the counterclaim is subject to the mandate in Fed.R. Civ.P. 13(a), we hold that § 6-5-440, Code of Alabama (1975), requires the dismissal of the subsequently filed state court action. That section reads as follows:
"No plaintiff is entitled to prosecute two actions in the courts of this state at the same time for the same cause and against the same party. In such a case, the defendant may require the plaintiff to elect which he will prosecute, if commenced simultaneously, and the pendency of the former is a good defense to the latter if commenced at different times."
The obvious intent of this statute is to forbid a party from prosecuting his claims in two courts simultaneously. It is not controverted that "courts of this state" as used in this section includes a United States district court within this state. Terrell v. City of Bessemer, 406 So.2d 337 (Ala.1981). In Terrell this Court allowed the plaintiff to pursue his state common-law theories of recovery after the federal court refused to exercise pendent jurisdiction over those claims, and by doing so, recognized an exception to the rule that controls this case. In this case the federal *585 court acquired jurisdiction of the controversy between these parties (based upon its diversity jurisdiction) before the state court action was filed. The exception to the general rule recognized in Terrell is, therefore, inapplicable here. Since the matter raised in the state court complaint constitutes a compulsory counterclaim in the federal court action that was pending at the time the state court action was commenced, the statute compels dismissal of the state court action. Accordingly, the petition for writ of mandamus is due to be granted.
WRIT GRANTED.
TORBERT, C.J., and MADDOX, JONES, ALMON, BEATTY, ADAMS, HOUSTON and STEAGALL, JJ., concur.
