ArvindSelvaraj
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import backend # Importing backend functions
|
|
|
3 |
|
4 |
# Title
|
5 |
st.title("Test Case Generator - QA User Story")
|
@@ -13,45 +14,39 @@ if st.button("Generate Test Cases"):
|
|
13 |
# Show a spinner while the test cases are being generated
|
14 |
with st.spinner("Generating test cases..."):
|
15 |
test_cases = backend.generate_testcases(user_story)
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
# Display the test cases in a readable format on the page
|
20 |
-
for idx, case in enumerate(test_cases, start=1):
|
21 |
-
st.write(f"**Test Case {idx}:**")
|
22 |
-
st.write(f"**Preconditions:** {case.get('Preconditions', 'N/A')}")
|
23 |
-
st.write(f"**Steps:** {case.get('Steps', 'N/A')}")
|
24 |
-
st.write(f"**Expected Result:** {case.get('Expected Result', 'N/A')}")
|
25 |
-
st.write("---") # Divider between test cases
|
26 |
-
|
27 |
-
# Store test cases in session state for further use (e.g., export)
|
28 |
-
st.session_state.test_cases = test_cases
|
29 |
-
else:
|
30 |
-
st.error("No test cases generated. Please try again with a different user story.")
|
31 |
else:
|
32 |
st.error("Please enter a user story to generate test cases.")
|
33 |
|
34 |
-
#
|
35 |
st.sidebar.title("Export Test Cases")
|
36 |
-
format = st.sidebar.selectbox("Select Format", ["
|
37 |
if st.sidebar.button("Export Test Cases", key="export_button"):
|
38 |
if 'test_cases' in st.session_state:
|
39 |
test_cases = st.session_state.test_cases
|
40 |
-
export_content = backend.export_test_cases(test_cases)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if export_content:
|
43 |
st.sidebar.download_button(
|
44 |
-
label="Download Test Cases as
|
45 |
data=export_content,
|
46 |
-
file_name="test_cases.
|
47 |
-
mime=
|
48 |
key="download_button"
|
49 |
)
|
50 |
-
else:
|
51 |
-
st.sidebar.error("Error exporting test cases. Please try again.")
|
52 |
else:
|
53 |
st.sidebar.error("No test cases available to export.")
|
54 |
|
55 |
# Footer with a clean divider
|
56 |
st.markdown("---")
|
57 |
-
st.write("Built by the QA Automation Team")
|
|
|
1 |
import streamlit as st
|
2 |
import backend # Importing backend functions
|
3 |
+
import os
|
4 |
|
5 |
# Title
|
6 |
st.title("Test Case Generator - QA User Story")
|
|
|
14 |
# Show a spinner while the test cases are being generated
|
15 |
with st.spinner("Generating test cases..."):
|
16 |
test_cases = backend.generate_testcases(user_story)
|
17 |
+
st.subheader("Generated Test Cases")
|
18 |
+
st.write(test_cases)
|
19 |
+
st.session_state.test_cases = test_cases # Store test cases in session state for further use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
else:
|
21 |
st.error("Please enter a user story to generate test cases.")
|
22 |
|
23 |
+
# Export test cases
|
24 |
st.sidebar.title("Export Test Cases")
|
25 |
+
format = st.sidebar.selectbox("Select Format", ["json", "csv"], key="export_format")
|
26 |
if st.sidebar.button("Export Test Cases", key="export_button"):
|
27 |
if 'test_cases' in st.session_state:
|
28 |
test_cases = st.session_state.test_cases
|
29 |
+
export_content = backend.export_test_cases(test_cases, format)
|
30 |
+
|
31 |
+
if format == 'json':
|
32 |
+
mime_type = "application/json"
|
33 |
+
elif format == 'csv':
|
34 |
+
mime_type = "text/csv"
|
35 |
+
else:
|
36 |
+
st.sidebar.error(f"Unsupported format: {format}")
|
37 |
+
export_content = None
|
38 |
|
39 |
if export_content:
|
40 |
st.sidebar.download_button(
|
41 |
+
label=f"Download Test Cases as {format.upper()}",
|
42 |
data=export_content,
|
43 |
+
file_name=f"test_cases.{format}",
|
44 |
+
mime=mime_type,
|
45 |
key="download_button"
|
46 |
)
|
|
|
|
|
47 |
else:
|
48 |
st.sidebar.error("No test cases available to export.")
|
49 |
|
50 |
# Footer with a clean divider
|
51 |
st.markdown("---")
|
52 |
+
st.write("Built by the QA Automation Team")
|