-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slack integration using slack bolt and testng to upload test report file
- Loading branch information
1 parent
ff10ced
commit e00553a
Showing
4 changed files
with
82 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/test/java/com/contentstack/cms/SlackReportingListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.contentstack.cms; | ||
import com.contentstack.cms.SanityReport; | ||
import io.github.cdimascio.dotenv.Dotenv; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.testng.ITestContext; | ||
import org.testng.ITestListener; | ||
import org.testng.ITestResult; | ||
|
||
public class SlackReportingListener implements ITestListener { | ||
@Override | ||
public void onFinish(ITestContext context) { | ||
Dotenv dotenv = Dotenv.load(); | ||
String slackToken = dotenv.get("SLACK_BOT_TOKEN"); | ||
String slackChannel = dotenv.get("SLACK_CHANNEL"); | ||
File input = new File("./target/site/surefire-report.html"); | ||
try { | ||
SanityReport.publishMessage( | ||
slackToken, | ||
slackChannel, | ||
SanityReport.buildSlackMessage(input), | ||
input | ||
); | ||
} catch (Exception e) { | ||
System.out.println("Error sending Slack message: " + e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite name="APISanityTestSuite" verbose="5" parallel="classes" | ||
thread-count="19" preserve-order="true"> | ||
|
||
<test name="Java Management SDK Sanity tests"> | ||
<classes> | ||
<class name="com.contentstack.cms.stack.APISanityTestSuite"/> | ||
</classes> | ||
</test> | ||
|
||
<listeners> | ||
<listener class-name="com.contentstack.cms.SlackReportingListener" /> | ||
</listeners> | ||
</suite> |