|
import streamlit as st |
|
import backend |
|
|
|
|
|
st.title("Test Case Generator - QA User Story") |
|
|
|
|
|
user_story = st.text_area("Enter the QA User Story", "") |
|
|
|
|
|
if st.button("Generate Test Cases"): |
|
if user_story: |
|
|
|
with st.spinner("Generating test cases..."): |
|
test_cases = backend.generate_testcases(user_story) |
|
|
|
if test_cases and not test_cases[0].get('Test Case') == "No test cases generated or output was empty.": |
|
st.subheader("Generated Test Cases") |
|
|
|
for idx, case in enumerate(test_cases, start=1): |
|
st.write(f"**Test Case {idx}:**") |
|
st.write(f"**Preconditions:** {case.get('Preconditions', 'N/A')}") |
|
st.write(f"**Steps:** {case.get('Steps', 'N/A')}") |
|
st.write(f"**Expected Result:** {case.get('Expected Result', 'N/A')}") |
|
st.write("---") |
|
|
|
|
|
st.session_state.test_cases = test_cases |
|
else: |
|
st.error("No test cases generated. Please try again with a different user story.") |
|
else: |
|
st.error("Please enter a user story to generate test cases.") |
|
|
|
|
|
st.sidebar.title("Export Test Cases") |
|
format = st.sidebar.selectbox("Select Format", ["excel"], key="export_format") |
|
if st.sidebar.button("Export Test Cases", key="export_button"): |
|
if 'test_cases' in st.session_state: |
|
test_cases = st.session_state.test_cases |
|
export_content = backend.export_test_cases(test_cases) |
|
|
|
if export_content: |
|
st.sidebar.download_button( |
|
label="Download Test Cases as EXCEL", |
|
data=export_content, |
|
file_name="test_cases.xlsx", |
|
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
|
key="download_button" |
|
) |
|
else: |
|
st.sidebar.error("Error exporting test cases. Please try again.") |
|
else: |
|
st.sidebar.error("No test cases available to export.") |
|
|
|
|
|
st.markdown("---") |
|
st.write("Built by the QA Automation Team") |
|
|